Skip to content

The logic around halt groups is broken by smp off; smp on sequence #1294

@en-sc

Description

@en-sc

There is an issue with bce93f6
Enabling SMP does not respect the SMP group identifier and always changes it to 1:

if (!strcmp(CMD_ARGV[0], "on")) {
foreach_smp_target(head, target->smp_targets)
head->target->smp = 1;
return ERROR_OK;
}

RISC-V targets use the SMP identifier as the identifier of the halt group the target is in:

if (target->smp) {
if (set_group(target, &info->haltgroup_supported, target->smp, HALT_GROUP) != ERROR_OK)
return ERROR_FAIL;
if (info->haltgroup_supported)
LOG_TARGET_INFO(target, "Core %d made part of halt group %d.", info->index,
target->smp);
else
LOG_TARGET_INFO(target, "Core %d could not be made part of halt group %d.",
info->index, target->smp);
}

if (info->haltgroup_supported) {
bool supported;
if (set_group(target, &supported, target->smp, HALT_GROUP) != ERROR_OK)
return ERROR_FAIL;
if (!supported)
LOG_TARGET_ERROR(target, "Couldn't place hart back in halt group %d. "
"Some harts may be unexpectedly halted.", target->smp);

Therefore, running smp off; smp on will change the halt group the hart is assumed to be a part of to 1, without re-configuring the DM.

AFAIU, there are two possible solutions to this issue:

  1. Decouple target->smp and the identifier of the SMP group by introducing something like target->smp_id. With smp on/off changing only target->smp.
  2. Decouple SMP groups and halt groups by introducing RISC-V specific commands that allow to configure halt groups. These commands can depend on the SMP (e.g. only the harts from the same SMP group can be made part of the same halt group with the check on resume whether the SMP group includes all the harts of the halt groups of the harts in the SMP groups).

IMHO the second option is preferable, however the first one is easier to implement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions