summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Wawrzynczak <twawrzynczak@chromium.org>2019-10-29 21:07:19 -0600
committerCommit Bot <commit-bot@chromium.org>2019-11-20 06:59:45 +0000
commit045d8afe4e7acfa96729e0ca765b454077761043 (patch)
tree50441b81470fe864864259bc082edcf2187405d6
parent7c407902be7b61b76cf8a73fce859d7068e4c533 (diff)
downloadvboot-045d8afe4e7acfa96729e0ca765b454077761043.tar.gz
battery cutoff: Move cutoff handling from EC sync to kernel load
Currently, battery cutoff is handled at the end of a successful EC software sync. Now that auxiliary firmware sync is separate from the EC, this patch moves it back to after both EC and auxfw updates are successful, to ensure all firmware is up-to-date before entering ship mode. BUG=none BRANCH=none TEST=make runtests Change-Id: I96bea22667ebf45b446a26d84de96e52f3d289a5 Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1889430 Reviewed-by: Julius Werner <jwerner@chromium.org> (cherry picked from commit 14128c66d5ad2c2caf50dbee1b19282497274a70) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1924299 Reviewed-by: Shelley Chen <shchen@chromium.org> Commit-Queue: Shelley Chen <shchen@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org>
-rw-r--r--firmware/2lib/2ec_sync.c33
-rw-r--r--firmware/lib/vboot_api_kernel.c28
2 files changed, 28 insertions, 33 deletions
diff --git a/firmware/2lib/2ec_sync.c b/firmware/2lib/2ec_sync.c
index 979c0a5d..b884cb85 100644
--- a/firmware/2lib/2ec_sync.c
+++ b/firmware/2lib/2ec_sync.c
@@ -448,35 +448,6 @@ static vb2_error_t ec_sync_phase2(struct vb2_context *ctx)
return sync_ec(ctx);
}
-/**
- * EC sync, phase 3
- *
- * This completes EC sync and handles battery cutoff if needed.
- *
- * @param ctx Vboot2 context
- * @return VB2_SUCCESS or non-zero error code.
- */
-static vb2_error_t ec_sync_phase3(struct vb2_context *ctx)
-{
- /* EC verification (and possibly updating / jumping) is done */
- vb2_error_t rv = vb2ex_ec_vboot_done(ctx);
- if (rv)
- return rv;
-
- /* Check if we need to cut-off battery. This must be done after EC
- * firmware updating and before kernel started. */
- if (vb2_nv_get(ctx, VB2_NV_BATTERY_CUTOFF_REQUEST)) {
- VB2_DEBUG("Request to cut-off battery\n");
- vb2_nv_set(ctx, VB2_NV_BATTERY_CUTOFF_REQUEST, 0);
- /* May lose power immediately, so commit our update now. */
- vb2_nv_commit(ctx);
- vb2ex_ec_battery_cutoff();
- return VBERROR_SHUTDOWN_REQUESTED;
- }
-
- return VB2_SUCCESS;
-}
-
vb2_error_t vb2api_ec_sync(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
@@ -509,8 +480,8 @@ vb2_error_t vb2api_ec_sync(struct vb2_context *ctx)
if (rv)
return rv;
- /* Phase 3; Completes sync and handles battery cutoff */
- rv = ec_sync_phase3(ctx);
+ /* Phase 3; Let the platform know that EC software sync is now done */
+ rv = vb2ex_ec_vboot_done(ctx);
if (rv)
return rv;
diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c
index facd1fea..a2062ff3 100644
--- a/firmware/lib/vboot_api_kernel.c
+++ b/firmware/lib/vboot_api_kernel.c
@@ -50,6 +50,26 @@ void vb2_nv_commit(struct vb2_context *ctx)
VbExNvStorageWrite(ctx->nvdata);
}
+static vb2_error_t handle_battery_cutoff(struct vb2_context *ctx)
+{
+ /*
+ * Check if we need to cut-off battery. This should be done after EC
+ * FW and Aux FW are updated, and before the kernel is started. This
+ * is to make sure all firmware is up-to-date before shipping (which
+ * is the typical use-case for cutoff).
+ */
+ if (vb2_nv_get(ctx, VB2_NV_BATTERY_CUTOFF_REQUEST)) {
+ VB2_DEBUG("Request to cut-off battery\n");
+ vb2_nv_set(ctx, VB2_NV_BATTERY_CUTOFF_REQUEST, 0);
+ /* May lose power immediately, so commit our update now. */
+ vb2_nv_commit(ctx);
+ vb2ex_ec_battery_cutoff();
+ return VBERROR_SHUTDOWN_REQUESTED;
+ }
+
+ return VB2_SUCCESS;
+}
+
uint32_t vb2_get_fwmp_flags(void)
{
return fwmp.flags;
@@ -367,8 +387,8 @@ vb2_error_t VbSelectAndLoadKernel(struct vb2_context *ctx,
VB2_DEBUG("GBB flags are %#x\n", vb2_get_gbb(ctx)->flags);
/*
- * Do EC software sync unless we're in recovery mode. This has UI but
- * it's just a single non-interactive WAIT screen.
+ * Do EC and Aux FW software sync unless we're in recovery mode. This
+ * has UI but it's just a single non-interactive WAIT screen.
*/
if (!(ctx->flags & VB2_CONTEXT_RECOVERY_MODE)) {
rv = vb2api_ec_sync(ctx);
@@ -378,6 +398,10 @@ vb2_error_t VbSelectAndLoadKernel(struct vb2_context *ctx,
rv = vb2api_auxfw_sync(ctx);
if (rv)
goto VbSelectAndLoadKernel_exit;
+
+ rv = handle_battery_cutoff(ctx);
+ if (rv)
+ goto VbSelectAndLoadKernel_exit;
}
/* Select boot path */