Jonathan Brandmeyer has uploaded this change for review. ( https://review.coreboot.org/27621
Change subject: chromeec: Read EC uptime info on boot. ......................................................................
chromeec: Read EC uptime info on boot.
Details: Additional diagnostic information about the EC and the most recent reasons why it has reset the AP are read out and logged via printk. This may aid in debugging spurious hangs and/or resets on the AP by providing traceability to the EC when it triggered the reset. Merely knowing that the EC was also recently reset may provide valuable intelligence. See also crrev.com/c/1139028.
Change-Id: Ie6abe645d5acefb570b9f6a3c4a4b60d5bcd63cd Signed-off-by: Jonathan Brandmeyer jbrandmeyer@chromium.org --- M src/ec/google/chromeec/ec.c 1 file changed, 110 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/21/27621/1
diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c index 734c90c..d8db074 100644 --- a/src/ec/google/chromeec/ec.c +++ b/src/ec/google/chromeec/ec.c @@ -892,8 +892,7 @@
#ifndef __SMM__
-static -int google_chromeec_hello(void) +static int google_chromeec_hello(void) { struct chromeec_command cec_cmd; struct ec_params_hello cmd_hello; @@ -912,6 +911,113 @@ return cec_cmd.cmd_code; }
+/* + * Copy the EC's information about resets of the AP and its own uptime for + * debugging purposes. + */ +static void google_chromeec_log_uptimeinfo(void) +{ + /* See also ChromiumOS EC include/chipset.h for details. */ + static const char * const reset_causes[] = { + "(reset unknown)", + "reset: board custom", + "reset: ap hang detected", + "reset: console command", + "reset: keyboard sysreset", + "reset: keyboard warm reboot", + "reset: debug warm reboot", + "reset: at AP's request", + "reset: during EC initialization", + "shutdown: power failure", + "shutdown: during EC initialization", + "shutdown: board custom", + "shutdown: battery voltage startup inhibit", + "shutdown: power wait asserted", + "shutdown: by console command", + "shutdown: entering G3", + "shutdown: thermal", + "shutdown: power button", + }; + + /* See also ChromiumOS EC include/system.h RESET_FLAG for details. */ + static const char * const reset_flag_strings[] = { + "other", + "reset-pin", + "brownout", + "power-on", + "watchdog", + "soft", + "hibernate", + "rtc-alarm", + "wake-pin", + "low-battery", + "sysjump", + "hard", + "ap-off", + "preserved", + "usb-resume", + "rdd", + "rbox", + "security" + }; + struct ec_response_uptime_info cmd_resp; + int i, flag, flag_count; + uint32_t reset_cause; + + struct chromeec_command get_uptime_cmd = { + .cmd_code = EC_CMD_GET_UPTIME_INFO, + .cmd_version = 0, + .cmd_data_in = NULL, + .cmd_size_in = 0, + .cmd_data_out = &cmd_resp, + .cmd_size_out = sizeof(cmd_resp), + .cmd_dev_index = 0, + }; + google_chromeec_command(&get_uptime_cmd); + if (get_uptime_cmd.cmd_code) { + /* + * Deliberately say nothing for EC's that don't support this + * command + */ + return; + } + + printk(BIOS_DEBUG, "Google Chrome EC uptime: %d.%03d seconds\n", + cmd_resp.time_since_ec_boot_ms / 1000, + cmd_resp.time_since_ec_boot_ms % 1000); + + printk(BIOS_DEBUG, "Google Chrome AP resets since EC boot: %d\n", + cmd_resp.ap_resets_since_ec_boot); + + printk(BIOS_DEBUG, "Google Chrome Most recent AP reset causes:\n"); + for (i = 0; i != ARRAY_SIZE(cmd_resp.recent_ap_reset); ++i) { + if (cmd_resp.recent_ap_reset[i].reset_time_ms == 0) + continue; + + /* Array access guard */ + reset_cause = cmd_resp.recent_ap_reset[i].reset_cause; + if (reset_cause >= ARRAY_SIZE(reset_causes)) + reset_cause = 0; + + printk(BIOS_DEBUG, "\t%d.%03d: %s\n", + cmd_resp.recent_ap_reset[i].reset_time_ms / 1000, + cmd_resp.recent_ap_reset[i].reset_time_ms % 1000, + reset_causes[reset_cause]); + } + + printk(BIOS_DEBUG, "Google Chrome EC reset flags at last EC boot: "); + flag_count = 0; + for (flag = 0; flag != ARRAY_SIZE(reset_flag_strings); ++flag) { + if ((cmd_resp.ec_reset_flags & (1 << flag)) != 0) { + if (flag_count) + printk(BIOS_DEBUG, " | "); + printk(BIOS_DEBUG, reset_flag_strings[flag]); + flag_count++; + } + } + printk(BIOS_DEBUG, "\n"); +} + static int ec_image_type; /* Cached EC image type (ro or rw). */
void google_chromeec_init(void) @@ -919,8 +1025,6 @@ struct chromeec_command cec_cmd; struct ec_response_get_version cec_resp = {{0}};
- printk(BIOS_DEBUG, "Google Chrome EC: Initializing keyboard.\n"); - google_chromeec_hello();
cec_cmd.cmd_code = EC_CMD_GET_VERSION; @@ -942,6 +1046,8 @@ cec_resp.current_image); ec_image_type = cec_resp.current_image; } + + google_chromeec_log_uptimeinfo(); }
int google_ec_running_ro(void)