[PATCH 29/32] bloblist: Support initing from multiple places
Simon Glass
sjg at chromium.org
Wed Aug 30 20:05:00 CEST 2023
Typically the bloblist is set up after the devicetree is present. This
makes sense because bloblist may use malloc() to allocate the space it
needs.
However sometimes the devicetree itself may be present in the bloblist.
In that case it is at a known location in memory so we can init the
bloblist very early, before devicetree.
Add a flag to indicate whether the bloblist has been inited. Add a
function to init it only if needed. Use that in the init sequence.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
common/bloblist.c | 13 ++++++++++++-
common/board_f.c | 4 +---
include/asm-generic/global_data.h | 4 ++++
include/bloblist.h | 18 ++++++++++++++++++
4 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/common/bloblist.c b/common/bloblist.c
index 2144b10e1d0..6f2a4577708 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -476,6 +476,17 @@ int bloblist_init(void)
log_debug("Found existing bloblist size %lx at %lx\n", size,
addr);
}
+ if (ret)
+ return log_msg_ret("ini", ret);
+ gd->flags |= GD_FLG_BLOBLIST_READY;
+
+ return 0;
+}
- return ret;
+int bloblist_maybe_init(void)
+{
+ if (CONFIG_IS_ENABLED(BLOBLIST) && !(gd->flags & GD_FLG_BLOBLIST_READY))
+ return bloblist_init();
+
+ return 0;
}
diff --git a/common/board_f.c b/common/board_f.c
index 2f986d9b289..76ae415487d 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -853,9 +853,7 @@ static const init_fnc_t init_sequence_f[] = {
log_init,
initf_bootstage, /* uses its own timer, so does not need DM */
event_init,
-#ifdef CONFIG_BLOBLIST
- bloblist_init,
-#endif
+ bloblist_maybe_init,
setup_spl_handoff,
#if defined(CONFIG_CONSOLE_RECORD_INIT_F)
console_record_init,
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index edf9ff6823f..b0485f3dd2a 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -674,6 +674,10 @@ enum gd_flags {
* @GD_FLG_OF_TAG_MIGRATE: Device tree has old u-boot,dm- tags
*/
GD_FLG_OF_TAG_MIGRATE = 0x200000,
+ /**
+ * @GD_FLG_BLOBLIST_READY: bloblist is ready for use
+ */
+ GD_FLG_BLOBLIST_READY = 0x400000,
};
#endif /* __ASSEMBLY__ */
diff --git a/include/bloblist.h b/include/bloblist.h
index 7ea72c6bd46..080cc46a126 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -413,8 +413,26 @@ void bloblist_reloc(void *to, uint to_size, void *from, uint from_size);
* standard passage. The size is detected automatically so CONFIG_BLOBLIST_SIZE
* can be 0.
*
+ * Sets GD_FLG_BLOBLIST_READY in global_data flags on success
+ *
* Return: 0 if OK, -ve on error
*/
int bloblist_init(void);
+#if CONFIG_IS_ENABLED(BLOBLIST)
+/**
+ * bloblist_maybe_init() - Init the bloblist system if not already done
+ *
+ * Calls bloblist_init() if the GD_FLG_BLOBLIST_READY flag is not et
+ *
+ * Return: 0 if OK, -ve on error
+ */
+int bloblist_maybe_init(void);
+#else
+static inline int bloblist_maybe_init(void)
+{
+ return 0;
+}
+#endif /* BLOBLIST */
+
#endif /* __BLOBLIST_H */
--
2.42.0.rc2.253.gd59a3bf2b4-goog
More information about the U-Boot
mailing list