diff mbox series

[09/18] capsule: Accept a bank on a successful update

Message ID 20240122115439.653871-10-sughosh.ganu@linaro.org
State Superseded
Headers show
Series FWU: Migrate FWU metadata to version 2 | expand

Commit Message

Sughosh Ganu Jan. 22, 2024, 11:54 a.m. UTC
The version 2 of the FWU metadata maintains a bank_state field per
bank, which keeps an aggregate status of the bank. A bank can either
be in a valid, invalid, or accepted state.

Update the bank_state field of the metadata once the update has gone
through successfully(when skipping Trial State), or once the images in
the bank have been accepted.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
---
 lib/efi_loader/efi_capsule.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index 0e6a38b441..422bb11162 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -480,6 +480,12 @@  static __maybe_unused efi_status_t fwu_empty_capsule_process(
 		if (ret != EFI_SUCCESS)
 			log_err("Unable to set the Accept bit for the image %pUs\n",
 				image_guid);
+
+		status = fwu_bank_state_update(active_idx);
+		ret = fwu_to_efi_error(status);
+		if (ret != EFI_SUCCESS)
+			log_err("Unable to update the bank_state for bank %u\n",
+				active_idx);
 	}
 
 	return ret;
@@ -525,6 +531,10 @@  static __maybe_unused efi_status_t fwu_post_update_process(bool fw_accept_os)
 			status = fwu_trial_state_start(update_index);
 			if (status < 0)
 				ret = EFI_DEVICE_ERROR;
+		} else {
+			status = fwu_bank_state_update(update_index);
+			if (status < 0)
+				ret = EFI_DEVICE_ERROR;
 		}
 	}