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-01-25 01:18:35 +0000
commit0f1e9b68c6af3e53d854bdc0ea6635fbce9e922e (patch)
tree83c260041fdc5f3d0d8ce712ddb16849260c1b02
parentbbd33ef5c3cc52d4fd52cd6cd7f30ff6f8588aa2 (diff)
downloadvboot-0f1e9b68c6af3e53d854bdc0ea6635fbce9e922e.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> (cherry picked from commit b00bf851cdaada874b7c66c6913d0cef0798fcbf) Reviewed-on: https://chromium-review.googlesource.com/885141 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/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;
}