summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2021-10-11 12:50:25 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-03-28 18:17:37 +0000
commit768322d728e8e9228b8ce46dfbf0c8954b8650c4 (patch)
treef1884a61305a8957955756ec35172ffaf51028de
parent5822c27c9775e21410e98ab72c64eb4c1b198e84 (diff)
downloadchrome-ec-768322d728e8e9228b8ce46dfbf0c8954b8650c4.tar.gz
mec1322/timer: Unroll udelay
This patch flattens udelay by unrolling __hw_clock_source_read. This increases the chance that we record LR of the instruction near which an infinite loop happened. BUG=b:218982018,b:200593658 BRANCH= TEST=buildall Change-Id: I8127e9a3308c161fd064e78048d82972bb57e464 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> (cherry picked from commit f0a9a2701fee604ec721b6a23173cec12cd8f4f0) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3508423
-rw-r--r--chip/mec1322/hwtimer.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/chip/mec1322/hwtimer.c b/chip/mec1322/hwtimer.c
index be9ffac1ea..221633d3f4 100644
--- a/chip/mec1322/hwtimer.c
+++ b/chip/mec1322/hwtimer.c
@@ -107,3 +107,14 @@ int __hw_clock_source_init(uint32_t start_t)
return MEC1322_IRQ_TIMER32_1;
}
+
+/*
+ * Unrolled udelay. It preserves LR, which points to the root cause of WD crash.
+ */
+__override void udelay(unsigned us)
+{
+ unsigned t0 = 0xffffffff - MEC1322_TMR32_CNT(0);
+
+ while (0xffffffff - MEC1322_TMR32_CNT(0) - t0 <= us)
+ ;
+}