[PATCH v3 0/3] EFI: Use sysreset instead of reset command

Hi,
Here is the 3rd version of the series to use sysreset instead of do_reset command interface for resetting after capsule update on disk. This change requires EFI capsule update on disk to depends on sysreset.
This adds two fixes from the previous patch: - [1/3] Disable 'capsule disk-update' of efidebug command when CONFIG_EFI_CAPSULE_ON_DISK is disabled. - [2/3] Make efi_load_capsule_drivers() available even if the CONFIG_EFI_CAPSULE_ON_DISK is disabled. And add Reviewed-by from Simon and Heinrich to [3/3].
Thank you,
---
Masami Hiramatsu (3): cmd: efidebug: Disable 'capsule disk-update' when CONFIG_EFI_CAPSULE_ON_DISK=n efi_loader: Make efi_load_capsule_drivers() available even if EFI_CAPSULE_ON_DISK=n efi_loader: Use sysreset instead of reset command
cmd/efidebug.c | 4 +++ lib/efi_loader/Kconfig | 1 + lib/efi_loader/efi_capsule.c | 65 +++++++++++++++++++++--------------------- 3 files changed, 38 insertions(+), 32 deletions(-)
-- Masami Hiramatsu masami.hiramatsu@linaro.org

Disable 'capsule disk-update' option for the efidebug command when CONFIC_EFI_CAPSULE_ON_DISK is disabled, because this option is available only when the EFI capsule update on disk is enabled.
Signed-off-by: Masami Hiramatsu masami.hiramatsu@linaro.org Suggested-by: Heinrich Schuchardt xypron.glpk@gmx.de --- cmd/efidebug.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 401d13cc4c..a1a0717ecb 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -84,6 +84,7 @@ static int do_efi_capsule_update(struct cmd_tbl *cmdtp, int flag, return CMD_RET_SUCCESS; }
+#ifdef CONFIG_EFI_CAPSULE_ON_DISK static int do_efi_capsule_on_disk_update(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) { @@ -93,6 +94,7 @@ static int do_efi_capsule_on_disk_update(struct cmd_tbl *cmdtp, int flag,
return ret == EFI_SUCCESS ? CMD_RET_SUCCESS : CMD_RET_FAILURE; } +#endif
/** * do_efi_capsule_show() - show capsule information @@ -303,8 +305,10 @@ static struct cmd_tbl cmd_efidebug_capsule_sub[] = { U_BOOT_CMD_MKENT(esrt, CONFIG_SYS_MAXARGS, 1, do_efi_capsule_esrt, "", ""), #endif +#ifdef CONFIG_EFI_CAPSULE_ON_DISK U_BOOT_CMD_MKENT(disk-update, 0, 0, do_efi_capsule_on_disk_update, "", ""), +#endif U_BOOT_CMD_MKENT(result, CONFIG_SYS_MAXARGS, 1, do_efi_capsule_res, "", ""), };

Make efi_load_capsule_drivers() available even if EFI_CAPSULE_ON_DISK is disabled because the caller (efi_init_obj_list()) expects it only relays on EFI_HAVE_CAPSULE_SUPPORT.
Signed-off-by: Masami Hiramatsu masami.hiramatsu@linaro.org Suggested-by: Heinrich Schuchardt xypron.glpk@gmx.de --- lib/efi_loader/efi_capsule.c | 60 +++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 30 deletions(-)
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c index 613b531b82..9fd6f78ad9 100644 --- a/lib/efi_loader/efi_capsule.c +++ b/lib/efi_loader/efi_capsule.c @@ -619,6 +619,36 @@ out: return EFI_EXIT(ret); }
+/** + * efi_load_capsule_drivers - initialize capsule drivers + * + * Generic FMP drivers backed by DFU + * + * Return: status code + */ +efi_status_t __weak efi_load_capsule_drivers(void) +{ + __maybe_unused efi_handle_t handle; + efi_status_t ret = EFI_SUCCESS; + + if (IS_ENABLED(CONFIG_EFI_CAPSULE_FIRMWARE_FIT)) { + handle = NULL; + ret = EFI_CALL(efi_install_multiple_protocol_interfaces( + &handle, &efi_guid_firmware_management_protocol, + &efi_fmp_fit, NULL)); + } + + if (IS_ENABLED(CONFIG_EFI_CAPSULE_FIRMWARE_RAW)) { + handle = NULL; + ret = EFI_CALL(efi_install_multiple_protocol_interfaces( + &handle, + &efi_guid_firmware_management_protocol, + &efi_fmp_raw, NULL)); + } + + return ret; +} + #ifdef CONFIG_EFI_CAPSULE_ON_DISK /** * get_dp_device - retrieve a device path from boot variable @@ -1007,36 +1037,6 @@ static void efi_capsule_scan_done(void) bootdev_root = NULL; }
-/** - * efi_load_capsule_drivers - initialize capsule drivers - * - * Generic FMP drivers backed by DFU - * - * Return: status code - */ -efi_status_t __weak efi_load_capsule_drivers(void) -{ - __maybe_unused efi_handle_t handle; - efi_status_t ret = EFI_SUCCESS; - - if (IS_ENABLED(CONFIG_EFI_CAPSULE_FIRMWARE_FIT)) { - handle = NULL; - ret = EFI_CALL(efi_install_multiple_protocol_interfaces( - &handle, &efi_guid_firmware_management_protocol, - &efi_fmp_fit, NULL)); - } - - if (IS_ENABLED(CONFIG_EFI_CAPSULE_FIRMWARE_RAW)) { - handle = NULL; - ret = EFI_CALL(efi_install_multiple_protocol_interfaces( - &handle, - &efi_guid_firmware_management_protocol, - &efi_fmp_raw, NULL)); - } - - return ret; -} - /** * check_run_capsules() - check whether capsule update should run *

Use sysreset_walk_halt() directly from reset-after-capsule-on-disk feature to reboot (cold reset) machine instead of using reset command interface, since this is not a command. Note that this will make CONFIG_EFI_CAPSULE_ON_DISK depending on the CONFIG_SYSRESET.
Signed-off-by: Masami Hiramatsu masami.hiramatsu@linaro.org Reviewed-by: Heinrich Schuchardt xypron.glpk@gmx.de Reviewed-by: Simon Glass sjg@chromium.org --- Changes in v2: - Add CONFIG_SYSRESET dependency. - Fix to add #include <sysreset.h> --- lib/efi_loader/Kconfig | 1 + lib/efi_loader/efi_capsule.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index e5e35fe51f..33138237cc 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -130,6 +130,7 @@ config EFI_RUNTIME_UPDATE_CAPSULE
config EFI_CAPSULE_ON_DISK bool "Enable capsule-on-disk support" + depends on SYSRESET select EFI_HAVE_CAPSULE_SUPPORT help Select this option if you want to use capsule-on-disk feature, diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c index 9fd6f78ad9..c6585cb113 100644 --- a/lib/efi_loader/efi_capsule.c +++ b/lib/efi_loader/efi_capsule.c @@ -18,6 +18,7 @@ #include <malloc.h> #include <mapmem.h> #include <sort.h> +#include <sysreset.h> #include <asm/global_data.h>
#include <crypto/pkcs7.h> @@ -1150,9 +1151,9 @@ efi_status_t efi_launch_capsules(void) * UEFI spec requires to reset system after complete processing capsule * update on the storage. */ - log_info("Reboot after firmware update"); + log_info("Reboot after firmware update.\n"); /* Cold reset is required for loading the new firmware. */ - do_reset(NULL, 0, 0, NULL); + sysreset_walk_halt(SYSRESET_COLD); hang(); /* not reach here */
participants (1)
-
Masami Hiramatsu