From 80bc32daf1692cf13b670e60725e195c1a568e8e Mon Sep 17 00:00:00 2001 From: Karthikeyan Ramasubramanian Date: Wed, 22 May 2019 11:33:40 -0600 Subject: [PATCH] lib/ec_sync_all: Reboot EC to RO after successful AUX FW update Currently some chips that require AUX FW update request EC reboot to RO after the FW update is applied successfully while some chips do not. It is safe to request EC reboot to RO whenever AUX FW update is applied successfully so that all the chips that require AUX FW update gets reset to a clean state. Update tests to handle the updated code flow and return code correctly. BUG=b:128820536,b:119046668 BRANCH=None TEST=Ensure that the device boots to ChromeOS. Force a TCPC FW update and ensure that after it is successfully applied EC reboots to RO. Cq-Depend: chromium:1625866 Change-Id: I72849620d90284e49cd1a9b31fc5eadede455c51 Signed-off-by: Karthikeyan Ramasubramanian Reviewed-on: https://chromium-review.googlesource.com/1627302 Tested-by: Karthikeyan Ramasubramanian Commit-Ready: Karthikeyan Ramasubramanian Legacy-Commit-Queue: Commit Bot Reviewed-by: Julius Werner --- firmware/lib/ec_sync_all.c | 20 ++++++++++++-------- tests/ec_sync_tests.c | 9 +++++---- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/firmware/lib/ec_sync_all.c b/firmware/lib/ec_sync_all.c index 7e6cbf34..f09b708f 100644 --- a/firmware/lib/ec_sync_all.c +++ b/firmware/lib/ec_sync_all.c @@ -78,14 +78,18 @@ VbError_t ec_sync_all(struct vb2_context *ctx) display_wait_screen(ctx, "AUX FW"); } - /* - * Do Aux FW software sync and protect devices tunneled through the EC. - * Aux FW update may request RO reboot to force EC cold reset so also - * disable display request if needed to prevent a second reboot. - */ - rv = ec_sync_update_aux_fw(ctx); - if (rv) - return rv; + if (fw_update > VB_AUX_FW_NO_UPDATE) { + /* Do Aux FW software sync */ + rv = ec_sync_update_aux_fw(ctx); + if (rv) + return rv; + /* + * AUX FW Update is applied successfully. Request EC reboot to + * RO, so that the chips that had FW update gets reset to a + * clean state. + */ + return VBERROR_EC_REBOOT_TO_RO_REQUIRED; + } /* Phase 3; Completes sync and handles battery cutoff */ rv = ec_sync_phase3(ctx); diff --git a/tests/ec_sync_tests.c b/tests/ec_sync_tests.c index 1698e032..44efb7de 100644 --- a/tests/ec_sync_tests.c +++ b/tests/ec_sync_tests.c @@ -469,12 +469,12 @@ static void VbSoftwareSyncTest(void) ResetMocks(); ec_aux_fw_mock_severity = VB_AUX_FW_FAST_UPDATE; - test_ssync(VBERROR_SUCCESS, 0, + test_ssync(VBERROR_EC_REBOOT_TO_RO_REQUIRED, 0, "Fast auxiliary FW update needed"); TEST_EQ(screens_count, 0, " wait screen skipped"); TEST_EQ(ec_aux_fw_update_req, 1, " aux fw update requested"); - TEST_EQ(ec_aux_fw_protected, 1, " aux fw protected"); + TEST_EQ(ec_aux_fw_protected, 0, " aux fw protected"); ResetMocks(); ec_aux_fw_mock_severity = VB_AUX_FW_SLOW_UPDATE; @@ -484,14 +484,15 @@ static void VbSoftwareSyncTest(void) ResetMocks(); ec_aux_fw_mock_severity = VB_AUX_FW_SLOW_UPDATE; - test_ssync(VBERROR_SUCCESS, 0, + test_ssync(VBERROR_EC_REBOOT_TO_RO_REQUIRED, 0, "Slow auxiliary FW update needed"); TEST_EQ(ec_aux_fw_update_req, 1, " aux fw update requested"); - TEST_EQ(ec_aux_fw_protected, 1, " aux fw protected"); + TEST_EQ(ec_aux_fw_protected, 0, " aux fw protected"); TEST_EQ(screens_displayed[0], VB_SCREEN_WAIT, " wait screen forced"); ResetMocks(); + ec_aux_fw_mock_severity = VB_AUX_FW_FAST_UPDATE; ec_aux_fw_retval = VBERROR_UNKNOWN; test_ssync(VBERROR_UNKNOWN, VB2_RECOVERY_AUX_FW_UPDATE, "Error updating AUX firmware");