Move back off timer to target struct
[openocd.git] / src / target / target.c
index 45b45770197d2bb569e034d1665a2ab5f9060748..d768fda7ea1b03b42d36fae21bc46fc62d7eac78 100644 (file)
@@ -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;
                }
        }
 

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)