diff options
author | Mathias K <kesmtp@freenet.de> | 2013-02-25 18:15:15 +0100 |
---|---|---|
committer | Spencer Oliver <spen@spen-soft.co.uk> | 2013-03-05 15:08:52 +0000 |
commit | 5d80b365526537d2e8705e8bf4de1485b4bb6be6 (patch) | |
tree | 84dbe7190c7123e2edf63f75a0c21012c74fa81e /src/target/target.c | |
parent | c4e0109644b6c9196c4a042804120da5fb46a8d6 (diff) |
Move back off timer to target struct
Move the global target back off timer to the target struct. This will
fix the wrong error handling with multi target devices like smp systems.
Change-Id: Ia327182ed5d13ca87323700017a8c40ecc6b25a3
Signed-off-by: Mathias K <kesmtp@freenet.de>
Reviewed-on: http://openocd.zylin.com/1179
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Diffstat (limited to 'src/target/target.c')
-rw-r--r-- | src/target/target.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/target/target.c b/src/target/target.c index 45b45770..d768fda7 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -2164,9 +2164,6 @@ static int sense_handler(void) return ERROR_OK; } -static int backoff_times; -static int backoff_count; - /* process target state changes */ static int handle_target(void *priv) { @@ -2222,13 +2219,6 @@ static int handle_target(void *priv) recursive = 0; } - if (backoff_times > backoff_count) { - /* do not poll this time as we failed previously */ - backoff_count++; - return ERROR_OK; - } - backoff_count = 0; - /* Poll targets for state changes unless that's globally disabled. * Skip targets that are currently disabled. */ @@ -2238,19 +2228,26 @@ static int handle_target(void *priv) if (!target->tap->enabled) continue; + if (target->backoff.times > target->backoff.count) { + /* do not poll this time as we failed previously */ + target->backoff.count++; + continue; + } + target->backoff.count = 0; + /* only poll target if we've got power and srst isn't asserted */ if (!powerDropout && !srstAsserted) { /* polling may fail silently until the target has been examined */ retval = target_poll(target); if (retval != ERROR_OK) { /* 100ms polling interval. Increase interval between polling up to 5000ms */ - if (backoff_times * polling_interval < 5000) { - backoff_times *= 2; - backoff_times++; + if (target->backoff.times * polling_interval < 5000) { + target->backoff.times *= 2; + target->backoff.times++; } LOG_USER("Polling target %s failed, GDB will be halted. Polling again in %dms", target_name(target), - backoff_times * polling_interval); + target->backoff.times * polling_interval); /* Tell GDB to halt the debugger. This allows the user to * run monitor commands to handle the situation. @@ -2259,9 +2256,9 @@ static int handle_target(void *priv) return retval; } /* Since we succeeded, we reset backoff count */ - if (backoff_times > 0) + if (target->backoff.times > 0) LOG_USER("Polling target %s succeeded again", target_name(target)); - backoff_times = 0; + target->backoff.times = 0; } } |