This is an automated email from Gerrit.

"Name of user not set <[email protected]>" just uploaded a new 
patch set to Gerrit, which you can find at 
https://review.openocd.org/c/openocd/+/9759

-- gerrit

commit a74c56b713a8a191a07816415d91efd29a21f487
Author: OpinionatedDeer <[email protected]>
Date:   Sat Jun 27 05:38:57 2026 +0530

    target/smp: preserve SMP group ID across smp off; smp on
    Running smp off; smp on changes the SMP group identifier of all targets
    in the group to 1, disregarding the original group number assigned by
    the target smp command. RISC-V targets use this identifier as the DM
    halt group ID, so the halt group becomes misconfigured without the DM
    being updated.
    Fix by introducing target->smp_id to store the persistent group
    identifier, separate from target->smp which is now purely an SMP
    enable/disable flag. The smp on command restores smp from smp_id
    
    Link: https://github.com/riscv-collab/riscv-openocd/issues/1294
    Change-Id: Ib719c0d275eca447bc1882d92dddc96657c8661f
    Signed-off-by: OpinionatedDeer <[email protected]>

diff --git a/src/target/smp.c b/src/target/smp.c
index 8a9dd2d9d7..657226b2da 100644
--- a/src/target/smp.c
+++ b/src/target/smp.c
@@ -106,7 +106,7 @@ COMMAND_HANDLER(default_handle_smp_command)
 
        if (!strcmp(CMD_ARGV[0], "on")) {
                foreach_smp_target(head, target->smp_targets)
-                       head->target->smp = 1;
+                       head->target->smp = head->target->smp_id;
 
                return ERROR_OK;
        }
diff --git a/src/target/target.c b/src/target/target.c
index 1b2bc8191b..99bc7d7182 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -2241,6 +2241,7 @@ static void free_smp_target_list(struct list_head 
*smp_targets)
        list_for_each_entry_safe(head, tmp, smp_targets, lh) {
                list_del(&head->lh);
                head->target->smp = 0;
+               head->target->smp_id = 0;
                head->target->smp_targets = &empty_smp_targets;
                free(head);
        }
@@ -6121,6 +6122,7 @@ COMMAND_HANDLER(handle_target_smp)
        foreach_smp_target(curr, lh) {
                struct target *target = curr->target;
                target->smp = smp_group;
+               target->smp_id = smp_group;
                target->smp_targets = lh;
        }
        smp_group++;
diff --git a/src/target/target.h b/src/target/target.h
index ce1fc728be..42d5e3ba43 100644
--- a/src/target/target.h
+++ b/src/target/target.h
@@ -197,7 +197,8 @@ struct target {
         * poll too quickly because we'll just overwhelm the user with error
         * messages. */
        struct backoff_timer backoff;
-       unsigned int smp;                                       /* Unique 
non-zero number for each SMP group */
+       unsigned int smp;                                       /* Non-zero if 
SMP is enabled, 0 if disabled */
+       unsigned int smp_id;                            /* Unique non-zero 
number for each SMP group */
        struct list_head *smp_targets;          /* list all targets in this smp 
group/cluster
                                                                                
 * The head of the list is shared between the
                                                                                
 * cluster, thus here there is a pointer */

-- 

Reply via email to