From 83dc8a6446ca8a8604dbd706373c1904d4004b97 Mon Sep 17 00:00:00 2001 From: Evgeniy Naydanov Date: Wed, 25 Dec 2024 13:11:33 +0300 Subject: [PATCH] target/riscv: clear `abstract_cmd_maybe_busy` after commands If a sufficient delay was used before reading `abstractcs` during the batch execution, `dm->abstract_cmd_maybe_busy` was not cleared and the following call to `wait_for_idle_if_needed()` (e.g. on `resume`), would result in a call to `wait_for_idle()` performing a redundant read of `abstractcs`. While this is not a bug, it impedes the performance. Change-Id: I9d234ef6d53af96c60892d71247c10e631dfcc3b Signed-off-by: Evgeniy Naydanov --- src/target/riscv/riscv-013.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index c399de7e4..3d6ba6c58 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -630,6 +630,15 @@ static int abstract_cmd_batch_check_and_clear_cmderr(struct target *target, if (res != ERROR_OK) goto clear_cmderr; } + + dm013_info_t * const dm = get_dm(target); + if (!dm) { + LOG_ERROR("BUG: Target %s is not assigned to any RISC-V debug module", + target_name(target)); + return ERROR_FAIL; + } + dm->abstract_cmd_maybe_busy = false; + *cmderr = get_field32(abstractcs, DM_ABSTRACTCS_CMDERR); if (*cmderr == CMDERR_NONE) return ERROR_OK;