summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/log.c5
-rw-r--r--common/spl/spl.c3
-rw-r--r--include/log.h12
3 files changed, 20 insertions, 0 deletions
diff --git a/common/log.c b/common/log.c
index b2de57fcb3b..42d35f04b68 100644
--- a/common/log.c
+++ b/common/log.c
@@ -428,6 +428,11 @@ int log_device_set_enable(struct log_driver *drv, bool enable)
return 0;
}
+void log_fixup_for_gd_move(struct global_data *new_gd)
+{
+ new_gd->log_head.prev->next = &new_gd->log_head;
+}
+
int log_init(void)
{
struct log_driver *drv = ll_entry_start(struct log_driver, log_driver);
diff --git a/common/spl/spl.c b/common/spl/spl.c
index b65c439e7aa..e06bc75d36b 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -909,6 +909,9 @@ ulong spl_relocate_stack_gd(void)
#if CONFIG_IS_ENABLED(DM)
dm_fixup_for_gd_move(new_gd);
#endif
+#if CONFIG_IS_ENABLED(LOG)
+ log_fixup_for_gd_move(new_gd);
+#endif
#if !defined(CONFIG_ARM) && !defined(CONFIG_RISCV)
gd = new_gd;
#endif
diff --git a/include/log.h b/include/log.h
index 6e84f080ef3..fc0d5984472 100644
--- a/include/log.h
+++ b/include/log.h
@@ -688,4 +688,16 @@ static inline int log_get_default_format(void)
(IS_ENABLED(CONFIG_LOGF_FUNC) ? BIT(LOGF_FUNC) : 0);
}
+struct global_data;
+/**
+ * log_fixup_for_gd_move() - Handle global_data moving to a new place
+ *
+ * @new_gd: Pointer to the new global data
+ *
+ * The log_head list is part of global_data. Due to the way lists work, moving
+ * the list will cause it to become invalid. This function fixes that up so
+ * that the log_head list will work correctly.
+ */
+void log_fixup_for_gd_move(struct global_data *new_gd);
+
#endif