summaryrefslogtreecommitdiff
path: root/common/timer.c
diff options
context:
space:
mode:
authorCraig Hesling <hesling@chromium.org>2020-03-15 14:30:46 -0700
committerCommit Bot <commit-bot@chromium.org>2020-03-21 09:14:52 +0000
commit4d032c74e0a77860875faa4bbab2974c71da4f13 (patch)
treefa987fc0ef857f8256813b2c7a56a297123b6b07 /common/timer.c
parent45e52682c29e0e08f25b0572ed16ad49cf559ee4 (diff)
downloadchrome-ec-4d032c74e0a77860875faa4bbab2974c71da4f13.tar.gz
waitms: Reload watchdog before spin waiting
This CL moved the reload watchdog operation to before the spin wait operation. This still achieves the goal of allowing back-to-back waitms calls and adds the ability to time watchdog behavior. Without this modification, you can't accurately test the watchdog timeout period. BRANCH=none BUG=b:151475816, b:151528646 TEST=make proj-nucleo-h743zi # Flash > clock hsi > waitms 10000 # Should see watchdog helper message at ~9 seconds Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: Id471a2667c913889c1aeba8bc14bb0f33458ed59 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2104494 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'common/timer.c')
-rw-r--r--common/timer.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/common/timer.c b/common/timer.c
index 843588f980..9a149f93e6 100644
--- a/common/timer.c
+++ b/common/timer.c
@@ -300,18 +300,20 @@ static int command_wait(int argc, char **argv)
return EC_ERROR_PARAM1;
/*
+ * Reload the watchdog so that issuing multiple small waitms commands
+ * quickly one after the other will not cause a reset.
+ *
+ * Reloading before waiting also allows for testing watchdog.
+ */
+ watchdog_reload();
+
+ /*
* Waiting for too long (e.g. 3s) will cause the EC to reset due to a
* watchdog timeout. This is intended behaviour and is in fact used by
* a FAFT test to check that the watchdog timer is working.
*/
udelay(i * 1000);
- /*
- * Reload the watchdog so that issuing multiple small waitms commands
- * quickly one after the other will not cause a reset.
- */
- watchdog_reload();
-
return EC_SUCCESS;
}
/* Typically a large delay (e.g. 3s) will cause a reset */