summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Norris <briannorris@chromium.org>2018-01-19 12:24:21 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2018-02-12 19:49:04 +0000
commit4cc08a7c9afdf344b5a0471779ee135c810c66e1 (patch)
tree8ff53028c5bcb13e531387a74ed8c4fee4b1167c
parentbc046644029a9b9af7f59ffde42308ed3d89b196 (diff)
downloadvboot-4cc08a7c9afdf344b5a0471779ee135c810c66e1.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: Icdb8eed92c74fe4ae10fec8e93d9e5754f10c730 Signed-off-by: Duncan Laurie <dlaurie@google.com> Original-Commit-Id: b00bf851cdaada874b7c66c6913d0cef0798fcbf Original-Change-Id: I1acf3aaeaf76f97f7603f79dbfef7a24a96f36dc Original-Signed-off-by: Brian Norris <briannorris@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/876783 Original-Reviewed-by: Philip Chen <philipchen@chromium.org> Original-Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/914550
-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 3f90ba5f..cc50b3b4 100644
--- a/firmware/lib/ec_sync.c
+++ b/firmware/lib/ec_sync.c
@@ -495,6 +495,8 @@ VbError_t ec_sync_phase3(struct vb2_context *ctx, VbCommonParams *cparams)
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;
}