diff mbox series

[v2,10/21] capsule: accept a bank on a successful update

Message ID 20240212074712.3657076-11-sughosh.ganu@linaro.org
State New
Headers show
Series FWU: Migrate FWU metadata to version 2 | expand

Commit Message

Sughosh Ganu Feb. 12, 2024, 7:47 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>
---

Changes since V1: None

 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;
 		}
 	}