summaryrefslogtreecommitdiff
path: root/chip/g/system.c
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2017-02-14 19:31:25 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-02-18 17:26:59 -0800
commit4ed404432904c3f8e6c9d64e8bb306daf3c687f5 (patch)
tree7b524aceeb143d5ed9a2bd120978c50cac8dd9db /chip/g/system.c
parent2062c99cd2bfe1642433b2cae33c617e02c27cdd (diff)
downloadchrome-ec-4ed404432904c3f8e6c9d64e8bb306daf3c687f5.tar.gz
cr50: Decrement retry counter on manual reboots.
Currently, manually triggered reboots cause the retry counter to be incremented. However, if the system is responsive enough to process the reboot commands from either the console or TPM vendor command, we can assume that the image is "ok". This commit changes the Cr50 behaviour to decrement the retry counter when a reboot is issued on the console or the TPM vendor command is received. BUG=chrome-os-partner:62687 BRANCH=None TEST=Flash cr50. Flash an older image in the other slot. Enter the reboot command on the console over 10 times and verify that retry counter never exceeds RW_BOOT_MAX_RETRY_COUNT and older image is never executed. CQ-DEPEND=CL:444264 Change-Id: Ic35bdc63c4141834584a00a7ecceab2abe8dfc21 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/443330 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to 'chip/g/system.c')
-rw-r--r--chip/g/system.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/chip/g/system.c b/chip/g/system.c
index ad553168c5..47b3848146 100644
--- a/chip/g/system.c
+++ b/chip/g/system.c
@@ -12,6 +12,7 @@
#include "registers.h"
#include "signed_header.h"
#include "system.h"
+#include "system_chip.h"
#include "task.h"
#include "version.h"
@@ -95,6 +96,13 @@ void system_reset(int flags)
#ifdef BOARD_CR50
/*
+ * Decrement the retry counter on manually triggered reboots. We were
+ * able to process the console command, therefore we're probably okay.
+ */
+ if (flags & SYSTEM_RESET_MANUALLY_TRIGGERED)
+ system_decrement_retry_counter();
+
+ /*
* On CR50 we want every reset be hard reset, causing the entire
* chromebook to reboot: we don't want the TPM reset while the AP
* stays up.
@@ -336,6 +344,17 @@ void system_clear_retry_counter(void)
GWRITE_FIELD(PMU, LONG_LIFE_SCRATCH_WR_EN, REG0, 0);
}
+void system_decrement_retry_counter(void)
+{
+ uint32_t val = GREG32(PMU, LONG_LIFE_SCRATCH0);
+
+ if (val != 0) {
+ GWRITE_FIELD(PMU, LONG_LIFE_SCRATCH_WR_EN, REG0, 1);
+ GREG32(PMU, LONG_LIFE_SCRATCH0) = val - 1;
+ GWRITE_FIELD(PMU, LONG_LIFE_SCRATCH_WR_EN, REG0, 0);
+ }
+}
+
/*
* Check which of the two cr50 RW images is newer, return true if the first
* image is no older than the second one.