summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Norris <briannorris@chromium.org>2018-01-19 12:24:21 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-01-19 20:35:48 -0800
commitb00bf851cdaada874b7c66c6913d0cef0798fcbf (patch)
tree4c53942876900dbef862085ed6b2ad537b82f31c
parente0b3841863281a3fc3b188bfbab55d401fabdc73 (diff)
downloadvboot-b00bf851cdaada874b7c66c6913d0cef0798fcbf.tar.gz
ec_sync: Commit NVRAM updates before battery cutoff
Battery cutoff may cause the entire system to lose power, which means that any uncommitted nvram updates will be lost. This can leave us in a battery cutoff loop, where we never completely clear the BATTERY_CUTOFF_REQUEST flag before actually cutting off power. The only way to escape this potential cutoff loop is if we manage to cleanly exit to vb2_kernel_cleanup(), where we perform a similar commit. But this requires us to retain power for some time after VbExEcBatteryCutOff(). BRANCH=none BUG=b:70176744 TEST=`crossystem battery_cutoff_request=1` on scarlet, then reboot; see battery cutoff; plug in AC and observe whether we reliably boot on first attach Change-Id: I1acf3aaeaf76f97f7603f79dbfef7a24a96f36dc Signed-off-by: Brian Norris <briannorris@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/876783 Reviewed-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
-rw-r--r--firmware/lib/ec_sync.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/firmware/lib/ec_sync.c b/firmware/lib/ec_sync.c
index d63ce4b7..83ad8025 100644
--- a/firmware/lib/ec_sync.c
+++ b/firmware/lib/ec_sync.c
@@ -473,6 +473,8 @@ VbError_t ec_sync_phase3(struct vb2_context *ctx)
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);
VbExEcBatteryCutOff();
return VBERROR_SHUTDOWN_REQUESTED;
}