With standard passage we can read the bloblist from global_data. Update the implementation to handle this, thus simplifying the code somewhat.
Shrink the log_msg_ret() string back down to a more normal size. Note that if OF_BLOBLIST is enabled, this code should never be reached unless there is a valid bloblist, since the devicetree is processed first. Signed-off-by: Simon Glass <s...@chromium.org> --- (no changes since v3) Changes in v3: - Add new patch to adjust how the bloblist is received from stdpass common/bloblist.c | 70 ++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 40 deletions(-) diff --git a/common/bloblist.c b/common/bloblist.c index 6e4f020d7c4..c7322b96bcb 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -11,6 +11,7 @@ #include <log.h> #include <malloc.h> #include <mapmem.h> +#include <passage.h> #include <spl.h> #include <tables_csum.h> #include <asm/global_data.h> @@ -513,47 +514,37 @@ int __weak xferlist_from_boot_arg(ulong __always_unused *addr) int bloblist_init(void) { bool fixed = IS_ENABLED(CONFIG_BLOBLIST_FIXED); - int ret = 0; - ulong addr = 0, size; - - /* Check if a valid transfer list passed in */ - if (!xferlist_from_boot_arg(&addr)) { - size = bloblist_get_total_size(); - } else { - /* - * If U-Boot is not in the first phase, an existing bloblist must - * be at a fixed address. - */ - bool from_addr = fixed && !xpl_is_first_phase(); - - /* - * If Firmware Handoff is mandatory but no transfer list is - * observed, report it as an error. - */ - if (IS_ENABLED(CONFIG_BLOBLIST_PASSAGE_MANDATORY)) - return -ENOENT; - - ret = -ENOENT; - - if (xpl_prev_phase() == PHASE_TPL && - !IS_ENABLED(CONFIG_TPL_BLOBLIST)) - from_addr = false; - if (fixed) - addr = IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED, - CONFIG_BLOBLIST_ADDR); - size = CONFIG_BLOBLIST_SIZE; - - if (from_addr) - ret = bloblist_check(addr, size); - - if (ret) - log_warning("Bloblist at %lx not found (err=%d)\n", + int ret = -ENOENT; + ulong addr, size; + bool expected; + + /** + * We don't expect to find an existing bloblist in the first phase of + * U-Boot that runs. The only way to receive the address of an allocated + * bloblist from a previous stage is with standard passage, so without + * that, the bloblist must be at a fixed address. + */ + expected = (fixed && !xpl_is_first_phase()) || passage_valid(); + if (xpl_prev_phase() == PHASE_TPL && !IS_ENABLED(CONFIG_TPL_BLOBLIST)) + expected = false; + if (fixed) + addr = IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED, + CONFIG_BLOBLIST_ADDR); + size = CONFIG_BLOBLIST_SIZE; + if (expected) { + if (passage_valid()) { + addr = gd_passage_bloblist(); + size = 0; + } + ret = bloblist_check(addr, size); + if (ret) { + log_warning("Expected bloblist at %lx not found (err=%d)\n", addr, ret); - else - /* Get the real size */ + } else { + /* Get the real size, if it is not what we expected */ size = gd->bloblist->total_size; + } } - if (ret) { /* * If we don't have a bloblist from a fixed address, or the one @@ -567,8 +558,7 @@ int bloblist_init(void) return log_msg_ret("alloc", -ENOMEM); addr = map_to_sysmem(ptr); } else if (!fixed) { - return log_msg_ret("BLOBLIST_FIXED is not enabled", - ret); + return log_msg_ret("!fixed", ret); } log_debug("Creating new bloblist size %lx at %lx\n", size, addr); -- 2.43.0