This is an automated email from Gerrit.

"Tomas Vanek <[email protected]>" just uploaded a new patch set to Gerrit, which 
you can find at https://review.openocd.org/c/openocd/+/9245

-- gerrit

commit e4f776372e637c1dbb70344b9fa53b393c16f729
Author: Tomas Vanek <[email protected]>
Date:   Fri Nov 21 12:01:34 2025 +0100

    target/aarch64: improve handling recursion in SMP halt
    
    update_halt_gdb() called aarch64_poll() recursively with temporary
    switching target's smp flag off to prevent deeper recursion.
    This was not possible for gdb assigned target or hwthread failed
    with "SMP node change, disconnect GDB from core/thread".
    Therefore the aarch64_poll(gdb_target) resulted in the useless
    recursion back to update_halt_gdb().
    
    Introduce aarch64_poll_smp() with smp parameter to avoid
    update_halt_gdb() recursion properly and without fiddling
    with target's smp flags.
    
    While on it, add 'aarch64_' prefix to update_halt_gdb() function.
    
    Change-Id: I645166f50c106f4a6d4d35dc70ad49041d2442aa
    Signed-off-by: Tomas Vanek <[email protected]>

diff --git a/src/target/aarch64.c b/src/target/aarch64.c
index ed9cb48aa7..4910714ba9 100644
--- a/src/target/aarch64.c
+++ b/src/target/aarch64.c
@@ -39,7 +39,7 @@ struct aarch64_private_config {
        struct arm_cti *cti;
 };
 
-static int aarch64_poll(struct target *target);
+static int aarch64_poll_smp(struct target *target, bool smp);
 static int aarch64_debug_entry(struct target *target);
 static int aarch64_restore_context(struct target *target, bool bpwp);
 static int aarch64_set_breakpoint(struct target *target,
@@ -469,7 +469,7 @@ static int aarch64_halt_smp(struct target *target, bool 
exc_target)
        return retval;
 }
 
-static int update_halt_gdb(struct target *target, enum target_debug_reason 
debug_reason)
+static int aarch64_update_halt_gdb(struct target *target, enum 
target_debug_reason debug_reason)
 {
        struct target *gdb_target = NULL;
        struct target_list *head;
@@ -498,15 +498,15 @@ static int update_halt_gdb(struct target *target, enum 
target_debug_reason debug
                if (curr == gdb_target)
                        continue;
 
-               /* avoid recursion in aarch64_poll() */
-               curr->smp = 0;
-               aarch64_poll(curr);
-               curr->smp = 1;
+               const bool smp = false;
+               aarch64_poll_smp(curr, smp);
        }
 
        /* after all targets were updated, poll the gdb serving target */
-       if (gdb_target && gdb_target != target)
-               aarch64_poll(gdb_target);
+       if (gdb_target && gdb_target != target) {
+               const bool smp = false;
+               aarch64_poll_smp(gdb_target, smp);
+       }
 
        return ERROR_OK;
 }
@@ -515,7 +515,7 @@ static int update_halt_gdb(struct target *target, enum 
target_debug_reason debug
  * Aarch64 Run control
  */
 
-static int aarch64_poll(struct target *target)
+static int aarch64_poll_smp(struct target *target, bool smp)
 {
        struct armv8_common *armv8 = target_to_armv8(target);
        enum target_state prev_target_state;
@@ -550,8 +550,8 @@ static int aarch64_poll(struct target *target)
                        if (retval != ERROR_OK)
                                return retval;
 
-                       if (target->smp)
-                               update_halt_gdb(target, debug_reason);
+                       if (smp)
+                               aarch64_update_halt_gdb(target, debug_reason);
 
                        if (arm_semihosting(target, &retval) != 0)
                                return retval;
@@ -578,6 +578,11 @@ static int aarch64_poll(struct target *target)
        return retval;
 }
 
+static int aarch64_poll(struct target *target)
+{
+       return aarch64_poll_smp(target, target->smp != 0);
+}
+
 static int aarch64_halt(struct target *target)
 {
        struct armv8_common *armv8 = target_to_armv8(target);

-- 

Reply via email to