From 911d68ef25ab6996110cc618279b600fe82591e5 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Fri, 9 Sep 2022 09:57:39 -0700 Subject: [PATCH] Don't read dmcontrol to set hartsel (#723) * Don't read dmcontrol to set hartsel We already know what dmcontrol should be. This addresses a long-standing TODO. In a toy test, this reduced the number of scans by 10+%. (Most of those are probably in poll(), so don't actually affect perceived performance.) Change-Id: I18e5ca391f0f5fb35f30d44dfef834e5a66aee20 Signed-off-by: Tim Newsome * Make code easier to read Co-authored-by: Jan Matyas <50193733+JanMatCodasip@users.noreply.github.com> Signed-off-by: Tim Newsome Signed-off-by: Tim Newsome Co-authored-by: Jan Matyas <50193733+JanMatCodasip@users.noreply.github.com> --- src/target/riscv/riscv-013.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 32b9cf7ff..24895e9ef 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -4110,10 +4110,7 @@ static int riscv013_select_current_hart(struct target *target) if (r->current_hartid == dm->current_hartid) return ERROR_OK; - uint32_t dmcontrol; - /* TODO: can't we just "dmcontrol = DMI_DMACTIVE"? */ - if (dmi_read(target, &dmcontrol, DM_DMCONTROL) != ERROR_OK) - return ERROR_FAIL; + uint32_t dmcontrol = DM_DMCONTROL_DMACTIVE; dmcontrol = set_hartsel(dmcontrol, r->current_hartid); int result = dmi_write(target, DM_DMCONTROL, dmcontrol); dm->current_hartid = r->current_hartid;