summaryrefslogtreecommitdiff
path: root/common/chipset.c
diff options
context:
space:
mode:
authorShannon Chen <shannc@google.com>2019-08-02 17:48:58 +0800
committerCommit Bot <commit-bot@chromium.org>2019-08-21 04:58:22 +0000
commit2fb1836646a1f4edcea1f22408535872b833d14e (patch)
tree3fead01aba3c47b18c85f462e88cf505fb4f4464 /common/chipset.c
parent10d0ea416eac754b94858c491efdd56cf1ef2476 (diff)
downloadchrome-ec-2fb1836646a1f4edcea1f22408535872b833d14e.tar.gz
log: Preserve Kukui EC reset logs across every EC reboot on SRAM.
On Kukui, we need to put console logs and reset reasons at fixed addresses on SRAM to save the information across each EC resets. Otherwise, EC will lose console logs and reset reasons after resetting EC. This CL ensures that the contents of reset and console logs will not be clobbered or cleared by putting mandatory symbols at a fixed location on SRAM. The values will only be reset when checksum or sanity check fails. BUG=b:133795403 TEST=1. On Kukui, shutdown AP, reboot AP, or sysjump, and see the previous logs before reboot will be kept on /var/log/croc_ec.log 2. Reset reasons can be viewed with ectool uptimeinfo BRANCH=master Change-Id: I19db49101fda1675dc2fdc047b7f14af77cdb6e6 Signed-off-by: Shannon Chen <shannc@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1716671 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Shannon Chen <shannc@chromium.org> Tested-by: Shannon Chen <shannc@chromium.org>
Diffstat (limited to 'common/chipset.c')
-rw-r--r--common/chipset.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/common/chipset.c b/common/chipset.c
index 427ea37940..9c11abe9c0 100644
--- a/common/chipset.c
+++ b/common/chipset.c
@@ -10,6 +10,7 @@
#include "console.h"
#include "ec_commands.h"
#include "host_command.h"
+#include "link_defs.h"
#include "system.h"
#include "task.h"
#include "timer.h"
@@ -60,10 +61,29 @@ DECLARE_HOST_COMMAND(EC_CMD_AP_RESET,
#ifdef CONFIG_CMD_AP_RESET_LOG
static struct mutex reset_log_mutex;
-static int next_reset_log;
+static int next_reset_log __preserved_logs(next_reset_log);
static uint32_t ap_resets_since_ec_boot;
/* keep reset_logs size a power of 2 */
-static struct ap_reset_log_entry reset_logs[4];
+static struct ap_reset_log_entry
+ reset_logs[4] __preserved_logs(reset_logs);
+static int reset_log_checksum __preserved_logs(reset_log_checksum);
+
+/* Calculate reset log checksum */
+static int calc_reset_log_checksum(void)
+{
+ return next_reset_log ^ reset_logs[next_reset_log].reset_cause;
+}
+
+/* Initialize reset logs and next reset log */
+void init_reset_log(void)
+{
+ if (next_reset_log < 0 || next_reset_log >= ARRAY_SIZE(reset_logs) ||
+ reset_log_checksum != calc_reset_log_checksum()) {
+ reset_log_checksum = 0;
+ next_reset_log = 0;
+ memset(&reset_logs, 0, sizeof(reset_logs));
+ }
+}
void report_ap_reset(enum chipset_shutdown_reason reason)
{
@@ -76,6 +96,9 @@ void report_ap_reset(enum chipset_shutdown_reason reason)
next_reset_log &= ARRAY_SIZE(reset_logs) - 1;
ap_resets_since_ec_boot++;
mutex_unlock(&reset_log_mutex);
+
+ /* Update checksum */
+ reset_log_checksum = calc_reset_log_checksum();
}
static int host_command_get_uptime_info(struct host_cmd_handler_args *args)