Furquan Shaikh (furquan@google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15897
-gerrit
commit b6e6274a1fab09cca5f781287180aaa96bf7edd0 Author: Furquan Shaikh furquan@google.com Date: Mon Jul 25 17:00:07 2016 -0700
chromeos: Clean up elog handling
1. Currenty, boot reason is being added to elog only for some ARM32/ARM64 platforms. Change this so that boot reason is logged by default in elog for all devices which have CHROMEOS selected. 2. Add a new option to select ELOG_WATCHDOG_RESET for the devices that want to add details about watchdog reset in elog. This requires a special region WATCHDOG to be present in the memlayout. 3. Remove calls to elog add boot reason and watchdog reset from mainboards.
Change-Id: I91ff5b158cfd2a0749e7fefc498d8659f7e6aa91 Signed-off-by: Furquan Shaikh furquan@google.com --- src/mainboard/google/gru/mainboard.c | 3 -- src/mainboard/google/nyan/mainboard.c | 4 --- src/mainboard/google/nyan_big/mainboard.c | 4 --- src/mainboard/google/nyan_blaze/mainboard.c | 4 --- src/mainboard/google/oak/mainboard.c | 4 --- src/mainboard/google/rush_ryu/mainboard.c | 3 -- src/mainboard/google/veyron/mainboard.c | 4 --- src/mainboard/google/veyron_brain/mainboard.c | 4 --- src/mainboard/google/veyron_danger/mainboard.c | 4 --- src/mainboard/google/veyron_emile/mainboard.c | 4 --- src/mainboard/google/veyron_mickey/mainboard.c | 4 --- src/mainboard/google/veyron_rialto/mainboard.c | 4 --- src/mainboard/google/veyron_romy/mainboard.c | 4 --- src/soc/mediatek/mt8173/Kconfig | 3 ++ src/soc/rockchip/rk3288/Kconfig | 1 + src/vendorcode/google/chromeos/Kconfig | 7 +++++ src/vendorcode/google/chromeos/Makefile.inc | 6 ++-- src/vendorcode/google/chromeos/chromeos.h | 6 ---- src/vendorcode/google/chromeos/elog.c | 40 ++++++++++++++++++-------- src/vendorcode/google/chromeos/watchdog.c | 10 +++++-- 20 files changed, 49 insertions(+), 74 deletions(-)
diff --git a/src/mainboard/google/gru/mainboard.c b/src/mainboard/google/gru/mainboard.c index 5a6b82c..7ec377f 100644 --- a/src/mainboard/google/gru/mainboard.c +++ b/src/mainboard/google/gru/mainboard.c @@ -189,9 +189,6 @@ static void mainboard_init(device_t dev) register_reset_to_bl31(); register_poweroff_to_bl31(); setup_rtc(); - - elog_init(); - elog_add_boot_reason(); }
static void enable_backlight_booster(void) diff --git a/src/mainboard/google/nyan/mainboard.c b/src/mainboard/google/nyan/mainboard.c index 48a0d1c..92bb3e3 100644 --- a/src/mainboard/google/nyan/mainboard.c +++ b/src/mainboard/google/nyan/mainboard.c @@ -242,10 +242,6 @@ static void mainboard_init(device_t dev) setup_kernel_info(); clock_init_arm_generic_timer(); setup_ec_spi(); -#if CONFIG_ELOG - elog_init(); - elog_add_boot_reason(); -#endif }
static void mainboard_enable(device_t dev) diff --git a/src/mainboard/google/nyan_big/mainboard.c b/src/mainboard/google/nyan_big/mainboard.c index a2fef3c..0c0fe5e 100644 --- a/src/mainboard/google/nyan_big/mainboard.c +++ b/src/mainboard/google/nyan_big/mainboard.c @@ -240,10 +240,6 @@ static void mainboard_init(device_t dev) setup_kernel_info(); clock_init_arm_generic_timer(); setup_ec_spi(); -#if CONFIG_ELOG - elog_init(); - elog_add_boot_reason(); -#endif }
static void mainboard_enable(device_t dev) diff --git a/src/mainboard/google/nyan_blaze/mainboard.c b/src/mainboard/google/nyan_blaze/mainboard.c index 7ceb123..c3b936c 100644 --- a/src/mainboard/google/nyan_blaze/mainboard.c +++ b/src/mainboard/google/nyan_blaze/mainboard.c @@ -240,10 +240,6 @@ static void mainboard_init(device_t dev) setup_kernel_info(); clock_init_arm_generic_timer(); setup_ec_spi(); -#if CONFIG_ELOG - elog_init(); - elog_add_boot_reason(); -#endif }
static void mainboard_enable(device_t dev) diff --git a/src/mainboard/google/oak/mainboard.c b/src/mainboard/google/oak/mainboard.c index 1bf8d49..1c9a8da 100644 --- a/src/mainboard/google/oak/mainboard.c +++ b/src/mainboard/google/oak/mainboard.c @@ -263,10 +263,6 @@ static void mainboard_init(device_t dev) configure_usb_hub(); configure_ext_buck(); configure_touchscreen(); - - elog_init(); - elog_add_watchdog_reset(); - elog_add_boot_reason(); }
static void mainboard_enable(device_t dev) diff --git a/src/mainboard/google/rush_ryu/mainboard.c b/src/mainboard/google/rush_ryu/mainboard.c index 28e2d99..8bc6d88 100644 --- a/src/mainboard/google/rush_ryu/mainboard.c +++ b/src/mainboard/google/rush_ryu/mainboard.c @@ -269,9 +269,6 @@ static void mainboard_init(device_t dev) /* Temp hack for P1 board: Enable speaker amp (powerup, etc.) */ enable_ad4567_spkr_amp();
- elog_init(); - elog_add_boot_reason(); - fix_ec_sw_sync();
/* configure panel gpio pads */ diff --git a/src/mainboard/google/veyron/mainboard.c b/src/mainboard/google/veyron/mainboard.c index cbc82e9..a6bbf88 100644 --- a/src/mainboard/google/veyron/mainboard.c +++ b/src/mainboard/google/veyron/mainboard.c @@ -108,10 +108,6 @@ static void mainboard_init(device_t dev) configure_emmc(); configure_codec(); configure_vop(); - - elog_init(); - elog_add_watchdog_reset(); - elog_add_boot_reason(); }
static void mainboard_enable(device_t dev) diff --git a/src/mainboard/google/veyron_brain/mainboard.c b/src/mainboard/google/veyron_brain/mainboard.c index 22faf64..cc07278 100644 --- a/src/mainboard/google/veyron_brain/mainboard.c +++ b/src/mainboard/google/veyron_brain/mainboard.c @@ -93,10 +93,6 @@ static void mainboard_init(device_t dev) configure_codec(); configure_vop(); configure_hdmi(); - - elog_init(); - elog_add_watchdog_reset(); - elog_add_boot_reason(); }
static void mainboard_enable(device_t dev) diff --git a/src/mainboard/google/veyron_danger/mainboard.c b/src/mainboard/google/veyron_danger/mainboard.c index f923da9..39f0b2a 100644 --- a/src/mainboard/google/veyron_danger/mainboard.c +++ b/src/mainboard/google/veyron_danger/mainboard.c @@ -149,10 +149,6 @@ static void mainboard_init(device_t dev) configure_codec(); configure_vop(); configure_hdmi(); - - elog_init(); - elog_add_watchdog_reset(); - elog_add_boot_reason(); }
static void mainboard_enable(device_t dev) diff --git a/src/mainboard/google/veyron_emile/mainboard.c b/src/mainboard/google/veyron_emile/mainboard.c index 5e9c1c1..b264df9 100644 --- a/src/mainboard/google/veyron_emile/mainboard.c +++ b/src/mainboard/google/veyron_emile/mainboard.c @@ -111,10 +111,6 @@ static void mainboard_init(device_t dev) configure_i2s(); configure_vop(); configure_hdmi(); - - elog_init(); - elog_add_watchdog_reset(); - elog_add_boot_reason(); }
static void mainboard_enable(device_t dev) diff --git a/src/mainboard/google/veyron_mickey/mainboard.c b/src/mainboard/google/veyron_mickey/mainboard.c index 27e9f74..ef085b2 100644 --- a/src/mainboard/google/veyron_mickey/mainboard.c +++ b/src/mainboard/google/veyron_mickey/mainboard.c @@ -87,10 +87,6 @@ static void mainboard_init(device_t dev) configure_i2s(); configure_vop(); configure_hdmi(); - - elog_init(); - elog_add_watchdog_reset(); - elog_add_boot_reason(); }
static void mainboard_enable(device_t dev) diff --git a/src/mainboard/google/veyron_rialto/mainboard.c b/src/mainboard/google/veyron_rialto/mainboard.c index 82c7b78..e32b52b 100644 --- a/src/mainboard/google/veyron_rialto/mainboard.c +++ b/src/mainboard/google/veyron_rialto/mainboard.c @@ -85,10 +85,6 @@ static void mainboard_init(device_t dev) configure_3g(); /* No video. */
- elog_init(); - elog_add_watchdog_reset(); - elog_add_boot_reason(); - /* If recovery mode is detected, reduce frequency and voltage to reduce * heat in case machine is left unattended. chrome-os-partner:41201. */ if (IS_ENABLED(CONFIG_VBOOT_VERIFY_FIRMWARE) && diff --git a/src/mainboard/google/veyron_romy/mainboard.c b/src/mainboard/google/veyron_romy/mainboard.c index c023338..9f68a09 100644 --- a/src/mainboard/google/veyron_romy/mainboard.c +++ b/src/mainboard/google/veyron_romy/mainboard.c @@ -86,10 +86,6 @@ static void mainboard_init(device_t dev) configure_emmc(); configure_codec(); configure_vop(); - - elog_init(); - elog_add_watchdog_reset(); - elog_add_boot_reason(); }
static void mainboard_enable(device_t dev) diff --git a/src/soc/mediatek/mt8173/Kconfig b/src/soc/mediatek/mt8173/Kconfig index ec3481e..f40df3b 100644 --- a/src/soc/mediatek/mt8173/Kconfig +++ b/src/soc/mediatek/mt8173/Kconfig @@ -18,6 +18,9 @@ config SOC_MEDIATEK_MT8173
if SOC_MEDIATEK_MT8173
+config CHROMEOS + select ELOG_WATCHDOG_RESET + config MEMORY_TEST bool default n diff --git a/src/soc/rockchip/rk3288/Kconfig b/src/soc/rockchip/rk3288/Kconfig index ea34bb9..cd6f962 100644 --- a/src/soc/rockchip/rk3288/Kconfig +++ b/src/soc/rockchip/rk3288/Kconfig @@ -36,6 +36,7 @@ config CHROMEOS select VBOOT_STARTS_IN_BOOTBLOCK select SEPARATE_VERSTAGE select RETURN_FROM_VERSTAGE + select ELOG_WATCHDOG_RESET
config PMIC_BUS int diff --git a/src/vendorcode/google/chromeos/Kconfig b/src/vendorcode/google/chromeos/Kconfig index a3cd11d..3d52bf7 100644 --- a/src/vendorcode/google/chromeos/Kconfig +++ b/src/vendorcode/google/chromeos/Kconfig @@ -36,6 +36,13 @@ config CHROMEOS
if CHROMEOS
+config ELOG_WATCHDOG_RESET + bool + default n + depends on ELOG + help + Log watchdog reset to elog + config VBNV_OFFSET hex default 0x26 diff --git a/src/vendorcode/google/chromeos/Makefile.inc b/src/vendorcode/google/chromeos/Makefile.inc index 590818f..391d43c 100644 --- a/src/vendorcode/google/chromeos/Makefile.inc +++ b/src/vendorcode/google/chromeos/Makefile.inc @@ -49,10 +49,8 @@ ramstage-$(CONFIG_CHROMEOS_RAMOOPS) += ramoops.c romstage-y += vpd_decode.c ramstage-y += vpd_decode.c cros_vpd.c vpd_mac.c vpd_serialno.c vpd_calibration.c ramstage-$(CONFIG_HAVE_REGULATORY_DOMAIN) += wrdd.c -ifeq ($(CONFIG_ARCH_X86)$(CONFIG_ARCH_MIPS),) -bootblock-y += watchdog.c -ramstage-y += watchdog.c -endif +bootblock-$(CONFIG_ELOG_WATCHDOG_RESET) += watchdog.c +ramstage-$(CONFIG_ELOG_WATCHDOG_RESET) += watchdog.c
ifeq ($(MOCK_TPM),1) CFLAGS_common += -DMOCK_TPM=1 diff --git a/src/vendorcode/google/chromeos/chromeos.h b/src/vendorcode/google/chromeos/chromeos.h index 04929d2..3188caf 100644 --- a/src/vendorcode/google/chromeos/chromeos.h +++ b/src/vendorcode/google/chromeos/chromeos.h @@ -28,16 +28,10 @@ void save_chromeos_gpios(void);
#if CONFIG_CHROMEOS -/* functions implemented in elog.c */ -void elog_add_boot_reason(void); - /* functions implemented in watchdog.c */ -void elog_add_watchdog_reset(void); void mark_watchdog_tombstone(void); void reboot_from_watchdog(void); #else -static inline void elog_add_boot_reason(void) { return; } -static inline void elog_add_watchdog_reset(void) { return; } static inline void mark_watchdog_tombstone(void) { return; } static inline void reboot_from_watchdog(void) { return; } #endif /* CONFIG_CHROMEOS */ diff --git a/src/vendorcode/google/chromeos/elog.c b/src/vendorcode/google/chromeos/elog.c index 062a5e1..5618909 100644 --- a/src/vendorcode/google/chromeos/elog.c +++ b/src/vendorcode/google/chromeos/elog.c @@ -13,6 +13,7 @@ * GNU General Public License for more details. */
+#include <bootstate.h> #include <cbmem.h> #include <console/console.h> #include <elog.h> @@ -20,19 +21,34 @@ #include <vendorcode/google/vboot2/vboot_common.h> #include <vboot_struct.h>
-void elog_add_boot_reason(void) +static void elog_add_boot_reason(void *unused) { - if (vboot_developer_mode_enabled()) { - elog_add_event(ELOG_TYPE_CROS_DEVELOPER_MODE); - printk(BIOS_DEBUG, "%s: Logged dev mode boot\n", __func__); - } else if (vboot_recovery_mode_enabled()) { - u8 reason = vboot_check_recovery_request(); - elog_add_event_byte(ELOG_TYPE_CROS_RECOVERY_MODE, - reason ? reason : ELOG_CROS_RECOVERY_MODE_BUTTON); - printk(BIOS_DEBUG, "%s: Logged recovery mode boot, " - "reason: 0x%02x\n", __func__, reason); - } else { + + if (!IS_ENABLED(CONFIG_ELOG)) + return; + + elog_init(); + + int rec = vboot_recovery_mode_enabled(); + int dev = vboot_developer_mode_enabled(); + + if (!rec && !dev) { printk(BIOS_DEBUG, "%s: Normal mode boot, nothing " - "interesting to log\n", __func__); + "interesting to log\n", __func__); + return; } + + if (rec) { + u8 reason = vboot_check_recovery_request(); + elog_add_event_byte(ELOG_TYPE_CROS_RECOVERY_MODE, reason); + printk(BIOS_DEBUG, "%s: Logged recovery mode boot%s, " + "reason: 0x%02x\n", __func__, + dev ?" (Dev-switch on)" : "", reason); + return; + } + + elog_add_event(ELOG_TYPE_CROS_DEVELOPER_MODE); + printk(BIOS_DEBUG, "%s: Logged dev mode boot\n", __func__); } + +BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_ENTRY, elog_add_boot_reason, NULL); diff --git a/src/vendorcode/google/chromeos/watchdog.c b/src/vendorcode/google/chromeos/watchdog.c index a2b18b7..8c9a071 100644 --- a/src/vendorcode/google/chromeos/watchdog.c +++ b/src/vendorcode/google/chromeos/watchdog.c @@ -14,6 +14,7 @@ */
#include <arch/io.h> +#include <bootstate.h> #include <console/console.h> #include <elog.h> #include <reset.h> @@ -23,13 +24,18 @@
#define WATCHDOG_TOMBSTONE_MAGIC 0x9d2f41a7
-void elog_add_watchdog_reset(void) +static void elog_add_watchdog_reset(void *unused) { - if (read32(_watchdog_tombstone) == WATCHDOG_TOMBSTONE_MAGIC) + if (read32(_watchdog_tombstone) == WATCHDOG_TOMBSTONE_MAGIC) { + elog_init(); elog_add_event(ELOG_TYPE_ASYNC_HW_TIMER_EXPIRED); + } write32(_watchdog_tombstone, 0); }
+BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_ENTRY, elog_add_watchdog_reset, + NULL); + void mark_watchdog_tombstone(void) { write32(_watchdog_tombstone, WATCHDOG_TOMBSTONE_MAGIC);