summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJonathan Brandmeyer <jbrandmeyer@chromium.org>2018-07-16 15:02:22 -0600
committerchrome-bot <chrome-bot@chromium.org>2018-07-26 04:07:41 -0700
commitdda2f778befed39e449d96b471b94d489ed23d60 (patch)
treefc0db938c092a609fbf47e9758d8f0113e5b0cce /include
parent48113728b689870e6aeda6534d36eeffd3b738b3 (diff)
downloadchrome-ec-dda2f778befed39e449d96b471b94d489ed23d60.tar.gz
reset: Log the reason for AP resets.
Provides a new EC host command 'uptime info' which gathers up some information which may be useful for debugging spurious resets on the AP (was the EC reset recently? Why was the EC reset? If the EC reset the AP, why did it do so?, etc.). Provide ectool support for the same. Example results of `ectool uptimeinfo`: ``` localhost ~ # ectool uptimeinfo EC uptime: 475.368 seconds AP resets since EC boot: 2 Most recent AP reset causes: 315.903: reset: console command 363.507: reset: keyboard warm reboot EC reset flags at last EC boot: reset-pin | sysjump ``` BRANCH=none TEST=Perform some `apreset` commands from the EC console and observe their side-effects via the `ectool uptimeinfo` command on the AP side. Test sequences include no-resets through 5 resets, observing that the ring buffer handling was correct. BUG=b:110788201, b:79529789 Signed-off-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Change-Id: I0bf29d69de471c64f905ee8aa070b15b4f34f2ba Reviewed-on: https://chromium-review.googlesource.com/1139028 Commit-Ready: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Tested-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/chipset.h85
-rw-r--r--include/config.h1
-rw-r--r--include/ec_commands.h49
3 files changed, 131 insertions, 4 deletions
diff --git a/include/chipset.h b/include/chipset.h
index 5169689d8a..5e51e5991a 100644
--- a/include/chipset.h
+++ b/include/chipset.h
@@ -39,6 +39,66 @@ enum chipset_state_mask {
CHIPSET_STATE_STANDBY),
};
+/*
+ * Reason codes used by the AP after a shutdown to figure out why it was reset
+ * by the EC. These are sent in EC commands. Therefore, to maintain protocol
+ * compatibility:
+ * - New entries must be inserted prior to the _COUNT field
+ * - If an existing entry is no longer in service, it must be replaced with a
+ * RESERVED entry instead.
+ * - The semantic meaning of an entry should not change.
+ * - Do not exceed 2^15 - 1 for reset reasons or 2^16 - 1 for shutdown reasons.
+ */
+enum chipset_reset_reason {
+ CHIPSET_RESET_BEGIN = 0,
+ CHIPSET_RESET_UNKNOWN = CHIPSET_RESET_BEGIN,
+ /* Custom reason defined by a board.c or baseboard.c file */
+ CHIPSET_RESET_BOARD_CUSTOM,
+ /* Believe that the AP has hung */
+ CHIPSET_RESET_HANG_REBOOT,
+ /* Reset by EC console command */
+ CHIPSET_RESET_CONSOLE_CMD,
+ /* Keyboard module reset key combination */
+ CHIPSET_RESET_KB_SYSRESET,
+ /* Keyboard module warm reboot */
+ CHIPSET_RESET_KB_WARM_REBOOT,
+ /* Debug module warm reboot */
+ CHIPSET_RESET_DBG_WARM_REBOOT,
+ /* I cannot self-terminate. You must lower me into the steel. */
+ CHIPSET_RESET_AP_REQ,
+ /* Reset as side-effect of startup sequence */
+ CHIPSET_RESET_INIT,
+ CHIPSET_RESET_COUNT,
+};
+
+/*
+ * Hard shutdowns are logged on the same path as resets.
+ */
+enum chipset_shutdown_reason {
+ CHIPSET_SHUTDOWN_BEGIN = 1 << 15,
+ CHIPSET_SHUTDOWN_POWERFAIL = CHIPSET_SHUTDOWN_BEGIN,
+ /* Forcing a shutdown as part of EC initialization */
+ CHIPSET_SHUTDOWN_INIT,
+ /* Custom reason on a per-board basis. */
+ CHIPSET_SHUTDOWN_BOARD_CUSTOM,
+ /* This is a reason to inhibit startup, not cause shut down. */
+ CHIPSET_SHUTDOWN_BATTERY_INHIBIT,
+ /* A power_wait_signal is being asserted */
+ CHIPSET_SHUTDOWN_WAIT,
+ /* Critical battery level. */
+ CHIPSET_SHUTDOWN_BATTERY_CRIT,
+ /* Because you told me to. */
+ CHIPSET_SHUTDOWN_CONSOLE_CMD,
+ /* Forcing a shutdown to effect entry to G3. */
+ CHIPSET_SHUTDOWN_G3,
+ /* Force shutdown due to over-temperature. */
+ CHIPSET_SHUTDOWN_THERMAL,
+ /* Force a chipset shutdown from the power button through EC */
+ CHIPSET_SHUTDOWN_BUTTON,
+
+ CHIPSET_SHUTDOWN_COUNT,
+};
+
#ifdef HAS_TASK_CHIPSET
/**
@@ -70,12 +130,12 @@ void chipset_throttle_cpu(int throttle);
* This is intended for use when the system is too hot or battery power is
* critical.
*/
-void chipset_force_shutdown(void);
+void chipset_force_shutdown(enum chipset_shutdown_reason reason);
/**
* Reset the CPU and/or chipset.
*/
-void chipset_reset(void);
+void chipset_reset(enum chipset_reset_reason reason);
/**
* Interrupt handler to power GPIO inputs.
@@ -102,8 +162,11 @@ static inline int chipset_in_state(int state_mask)
static inline void chipset_exit_hard_off(void) { }
static inline void chipset_throttle_cpu(int throttle) { }
-static inline void chipset_force_shutdown(void) { }
-static inline void chipset_reset(void) { }
+static inline void chipset_force_shutdown(enum chipset_shutdown_reason reason)
+{
+}
+
+static inline void chipset_reset(enum chipset_reset_reason reason) { }
static inline void power_interrupt(enum gpio_signal signal) { }
static inline void chipset_handle_espi_reset_assert(void) { }
static inline void chipset_handle_reboot(void) { }
@@ -139,4 +202,18 @@ void chipset_reset_request_interrupt(enum gpio_signal signal);
*/
void chipset_power_signal_interrupt(enum gpio_signal signal);
+
+#ifdef CONFIG_CMD_AP_RESET_LOG
+
+/**
+ * Report that the AP is being reset to the reset log.
+ */
+void report_ap_reset(enum chipset_shutdown_reason reason);
+
+#else
+
+static inline void report_ap_reset(enum chipset_shutdown_reason reason) { }
+
+#endif /* !CONFIG_CMD_AP_RESET_LOG */
+
#endif /* __CROS_EC_CHIPSET_H */
diff --git a/include/config.h b/include/config.h
index 719a10124c..0d363c4e57 100644
--- a/include/config.h
+++ b/include/config.h
@@ -953,6 +953,7 @@
#define CONFIG_CMD_USBMUX
#undef CONFIG_CMD_USB_PD_PE
#define CONFIG_CMD_WAITMS
+#undef CONFIG_CMD_AP_RESET_LOG
/*****************************************************************************/
diff --git a/include/ec_commands.h b/include/ec_commands.h
index f20113cf9c..ee91c80710 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -4796,6 +4796,55 @@ struct __ec_align1 ec_params_set_cbi {
uint8_t data[]; /* For string and raw data */
};
+/*
+ * Information about resets of the AP by the EC and the EC's own uptime.
+ */
+#define EC_CMD_GET_UPTIME_INFO 0x0121
+
+struct __ec_align4 ec_response_uptime_info {
+ /*
+ * Number of milliseconds since the last EC boot. Sysjump resets
+ * typically do not restart the EC's time_since_boot epoch.
+ *
+ * WARNING: The EC's sense of time is much less accurate than the AP's
+ * sense of time, in both phase and frequency. This timebase is similar
+ * to CLOCK_MONOTONIC_RAW, but with 1% or more frequency error.
+ */
+ uint32_t time_since_ec_boot_ms;
+
+ /*
+ * Number of times the AP was reset by the EC since the last EC boot.
+ * Note that the AP may be held in reset by the EC during the initial
+ * boot sequence, such that the very first AP boot may count as more
+ * than one here.
+ */
+ uint32_t ap_resets_since_ec_boot;
+
+ /*
+ * The set of flags which describe the EC's most recent reset. See
+ * include/system.h RESET_FLAG_* for details.
+ */
+ uint32_t ec_reset_flags;
+
+ /* Empty log entries have both the cause and timestamp set to zero. */
+ struct ap_reset_log_entry {
+ /*
+ * See include/chipset.h: enum chipset_{reset,shutdown}_reason
+ * for details.
+ */
+ uint16_t reset_cause;
+
+ /* Reserved for protocol growth. */
+ uint16_t reserved;
+
+ /*
+ * The time of the reset's assertion, in milliseconds since the
+ * last EC boot, in the same epoch as time_since_ec_boot_ms.
+ * Set to zero if the log entry is empty.
+ */
+ uint32_t reset_time_ms;
+ } recent_ap_reset[4];
+};
/*****************************************************************************/
/* The command range 0x200-0x2FF is reserved for Rotor. */