When global_data is relocated, log_head moves in memory, meaning that
the items in that list point to the wrong place.

Disable logging when making the change, then reenable it afterwards, so
that logging works normally.

Signed-off-by: Simon Glass <s...@chromium.org>
---

 arch/x86/lib/spl.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/x86/lib/spl.c b/arch/x86/lib/spl.c
index 0e1a18b251d7..3253b0a26062 100644
--- a/arch/x86/lib/spl.c
+++ b/arch/x86/lib/spl.c
@@ -137,9 +137,22 @@ static int x86_spl_init(void)
         */
        gd->new_gd = (struct global_data *)ptr;
        memcpy(gd->new_gd, gd, sizeof(*gd));
+
+       /*
+        * Make sure logging is disabled when we switch, since the log system
+        * list head will move
+        */
+       gd->new_gd->flags &= ~GD_FLG_LOG_READY;
        arch_setup_gd(gd->new_gd);
        gd->start_addr_sp = (ulong)ptr;
 
+       /* start up logging again, with the new list-head location */
+       ret = log_init();
+       if (ret) {
+               log_debug("Log setup failed (err=%d)\n", ret);
+               return ret;
+       }
+
        /* Cache the SPI flash. Otherwise copying the code to RAM takes ages */
        ret = mtrr_add_request(MTRR_TYPE_WRBACK,
                               (1ULL << 32) - CONFIG_XIP_ROM_SIZE,
-- 
2.40.0.348.gf938b09366-goog

Reply via email to