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 b89cddf11150db84d3b587bceca5f08337e2e158
Author: Bowen Wang <[email protected]>
AuthorDate: Tue Apr 14 20:50:21 2026 +0800

    drivers/rptun: pause the peers while this core prints its panic
    
    When a core panics, its peers keep running and keep printing, so on a
    shared console their output interleaves with the crash log.
    
    With CONFIG_RPTUN_AUTO_RESET_IN_PANIC_NOTIFIER, set a new
    RPTUN_STATUS_PAUSE bit for every peer at PANIC_KERNEL, before the crash
    log is printed; rptun_dev_reset() only sets it and does not wait. A peer
    that sees PAUSE in rptun_check_peer_status() busy-waits, up to
    CONFIG_RPTUN_STATUS_TIMEOUT_MS, until the panicking core sets PANIC at
    PANIC_KERNEL_FINAL, and then panics as before. RPTUN_STATUS_PAUSE is
    BOARDIOC_SOFTRESETCAUSE_MAX, the first bit after the reset causes.
    
    Also parenthesize RPTUN_STATUS_CHECK() so that it can be negated.
    
    Signed-off-by: Bowen Wang <[email protected]>
---
 drivers/rptun/rptun.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/drivers/rptun/rptun.c b/drivers/rptun/rptun.c
index 72a1d90a664..114b504fa03 100644
--- a/drivers/rptun/rptun.c
+++ b/drivers/rptun/rptun.c
@@ -57,7 +57,7 @@
 
 #define RPTUN_RETRY_PERIOD_US    1000
 
-#define RPTUN_STATUS_CHECK(s, v) ((s) & (1u << (v))) != 0
+#define RPTUN_STATUS_CHECK(s, v) (((s) & (1u << (v))) != 0)
 #define RPTUN_STATUS_SET(s, v)   ((s) |= (1u << (v)))
 #define RPTUN_REASON_GET(s)      (ffs(s) - 1u)
 
@@ -66,6 +66,8 @@
 
 #define rptunvbs(format, ...)    syslog(LOG_ALERT, format, ##__VA_ARGS__)
 
+#define RPTUN_STATUS_PAUSE       BOARDIOC_SOFTRESETCAUSE_MAX
+
 /****************************************************************************
  * Private Types
  ****************************************************************************/
@@ -938,6 +940,20 @@ static void rptun_check_peer_status(FAR struct 
rptun_priv_s *priv)
 
   status = rptun_get_peer_status(priv);
 
+  if (RPTUN_STATUS_CHECK(status, RPTUN_STATUS_PAUSE))
+    {
+      int timeout = CONFIG_RPTUN_STATUS_TIMEOUT_MS;
+
+      /* Wait for the crashing core to finish printing its log */
+
+      while (timeout-- > 0 &&
+             (!RPTUN_STATUS_CHECK(status, BOARDIOC_SOFTRESETCAUSE_PANIC)))
+        {
+          status = rptun_get_peer_status(priv);
+          up_udelay(1000);
+        }
+    }
+
   if (RPTUN_STATUS_CHECK(status, BOARDIOC_SOFTRESETCAUSE_PANIC))
     {
       char msg[64];
@@ -1178,6 +1194,11 @@ static int rptun_dev_reset(FAR struct rptun_priv_s 
*priv, unsigned long val)
     {
       rptun_set_status(priv, val);
 
+      if (val == RPTUN_STATUS_PAUSE)
+        {
+          return OK;
+        }
+
       ret = -ETIMEDOUT;
       while (timeout-- > 0)
         {
@@ -1449,6 +1470,11 @@ static int rptun_notifier(FAR struct notifier_block 
*block,
         }
 #endif
     }
+  else if (action == PANIC_KERNEL)
+    {
+      rptun_ioctl_foreach(NULL, RPTUNIOC_RESET,
+                          (unsigned long)RPTUN_STATUS_PAUSE);
+    }
 #ifdef CONFIG_RPTUN_AUTO_RESET_IN_PANIC_NOTIFIER
   else if (action == PANIC_KERNEL_FINAL)
     {

Reply via email to