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

xiaoxiang 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 35240d77fa Revert "SYSLOG_DEFAULT: wrap up_putc/up_nputs calls with 
critical section"
35240d77fa is described below

commit 35240d77faa0b5e00d0bb3e9024ac2dde7c8362a
Author: YAMAMOTO Takashi <[email protected]>
AuthorDate: Wed Nov 13 10:49:38 2024 +0900

    Revert "SYSLOG_DEFAULT: wrap up_putc/up_nputs calls with critical section"
    
    This reverts commit f2aeb5e56ff6ec7ba15958403289e462a8c84ab8.
    
    Because regressions are reported:
    * https://github.com/apache/nuttx/pull/14722#issuecomment-2470710236
    * https://github.com/apache/nuttx/pull/14722#issuecomment-2470778673
    * https://github.com/apache/nuttx/issues/14749
---
 drivers/serial/serial.c         |  4 ----
 drivers/syslog/syslog_channel.c | 23 ++++++++++-------------
 2 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c
index d475f44d12..6915e8d1f3 100644
--- a/drivers/serial/serial.c
+++ b/drivers/serial/serial.c
@@ -268,10 +268,6 @@ static int uart_putxmitchar(FAR uart_dev_t *dev, int ch, 
bool oktoblock)
         {
           /* The following steps must be atomic with respect to serial
            * interrupt handling.
-           *
-           * This critical section is also used for the serialization
-           * with the up_putc-based syslog channels.
-           * See https://github.com/apache/nuttx/issues/14662
            */
 
           flags = enter_critical_section();
diff --git a/drivers/syslog/syslog_channel.c b/drivers/syslog/syslog_channel.c
index 8038271d59..a7893359d7 100644
--- a/drivers/syslog/syslog_channel.c
+++ b/drivers/syslog/syslog_channel.c
@@ -33,6 +33,7 @@
 
 #include <nuttx/syslog/syslog.h>
 #include <nuttx/compiler.h>
+#include <nuttx/mutex.h>
 
 #ifdef CONFIG_RAMLOG_SYSLOG
 #  include <nuttx/syslog/ramlog.h>
@@ -71,6 +72,10 @@ static ssize_t syslog_default_write(FAR syslog_channel_t 
*channel,
  * Private Data
  ****************************************************************************/
 
+#if defined(CONFIG_SYSLOG_DEFAULT) && defined(CONFIG_ARCH_LOWPUTC)
+static mutex_t g_lowputs_lock = NXMUTEX_INITIALIZER;
+#endif
+
 #ifdef CONFIG_RAMLOG_SYSLOG
 static const struct syslog_channel_ops_s g_ramlog_channel_ops =
 {
@@ -229,17 +234,11 @@ g_syslog_channel[CONFIG_SYSLOG_MAX_CHANNELS] =
 #ifdef CONFIG_SYSLOG_DEFAULT
 static int syslog_default_putc(FAR syslog_channel_t *channel, int ch)
 {
-#  ifdef CONFIG_ARCH_LOWPUTC
-  /* See https://github.com/apache/nuttx/issues/14662
-   * about what this critical section is for.
-   */
+  UNUSED(channel);
 
-  irqstate_t flags = enter_critical_section();
+#  ifdef CONFIG_ARCH_LOWPUTC
   up_putc(ch);
-  leave_critical_section(flags);
 #  endif
-
-  UNUSED(channel);
   return ch;
 }
 
@@ -247,13 +246,11 @@ static ssize_t syslog_default_write(FAR syslog_channel_t 
*channel,
                                     FAR const char *buffer, size_t buflen)
 {
 #  ifdef CONFIG_ARCH_LOWPUTC
-  /* See https://github.com/apache/nuttx/issues/14662
-   * about what this critical section is for.
-   */
+  nxmutex_lock(&g_lowputs_lock);
 
-  irqstate_t flags = enter_critical_section();
   up_nputs(buffer, buflen);
-  leave_critical_section(flags);
+
+  nxmutex_unlock(&g_lowputs_lock);
 #  endif
 
   UNUSED(channel);

Reply via email to