Skip to content

Commit c05a10d

Browse files
committed
target/riscv: reset dmi.busy after batches
Additionally, avoid calling `riscv_batch_finished_scans()` / decrementing reset counter if the batch run failed. Change-Id: I3eb7b23e4dc029090e92e3e543719824add623e1 Signed-off-by: Evgeniy Naydanov <[email protected]>
1 parent 4b5668b commit c05a10d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/target/riscv/riscv-013.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2769,12 +2769,16 @@ static int batch_run(struct target *target, struct riscv_batch *batch)
27692769
const int result = riscv_batch_run_from(batch, 0, &info->learned_delays,
27702770
/*resets_delays*/ r->reset_delays_wait >= 0,
27712771
r->reset_delays_wait);
2772+
if (result != ERROR_OK)
2773+
return result;
27722774
/* TODO: To use `riscv_batch_finished_scans()` here, it is needed for
27732775
* all scans to not discard input, meaning
27742776
* "riscv_batch_add_dm_write(..., false)" should not be used. */
27752777
const size_t finished_scans = batch->used_scans;
27762778
decrement_reset_delays_counter(target, finished_scans);
2777-
return result;
2779+
if (riscv_batch_was_batch_busy(batch))
2780+
return increase_dmi_busy_delay(target);
2781+
return ERROR_OK;
27782782
}
27792783

27802784
/* It is expected that during creation of the batch
@@ -2797,12 +2801,12 @@ static int batch_run_timeout(struct target *target, struct riscv_batch *batch)
27972801
&info->learned_delays,
27982802
/*resets_delays*/ r->reset_delays_wait >= 0,
27992803
r->reset_delays_wait);
2804+
if (result != ERROR_OK)
2805+
return result;
28002806
const size_t new_finished_scans = riscv_batch_finished_scans(batch);
28012807
assert(new_finished_scans >= finished_scans);
28022808
decrement_reset_delays_counter(target, new_finished_scans - finished_scans);
28032809
finished_scans = new_finished_scans;
2804-
if (result != ERROR_OK)
2805-
return result;
28062810
if (!riscv_batch_was_batch_busy(batch)) {
28072811
assert(finished_scans == batch->used_scans);
28082812
return ERROR_OK;

0 commit comments

Comments
 (0)