mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-18 02:44:37 +00:00
log: fixup log_head after relocating global data
When `gd` is relocated during `spl_relocate_stack_gd()` the doubly-linked circular list in the `log_head` member is broken. The last element of the list should point back to the initial `list_head`, but as the initial `list_head` is moved the pointer becomes stale. As a result the loop in `log_dispatch` would never finish. Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
This commit is contained in:
parent
657bd30c6b
commit
39162d9348
3 changed files with 20 additions and 0 deletions
|
@ -428,6 +428,11 @@ int log_device_set_enable(struct log_driver *drv, bool enable)
|
||||||
return 0;
|
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)
|
int log_init(void)
|
||||||
{
|
{
|
||||||
struct log_driver *drv = ll_entry_start(struct log_driver, log_driver);
|
struct log_driver *drv = ll_entry_start(struct log_driver, log_driver);
|
||||||
|
|
|
@ -909,6 +909,9 @@ ulong spl_relocate_stack_gd(void)
|
||||||
#if CONFIG_IS_ENABLED(DM)
|
#if CONFIG_IS_ENABLED(DM)
|
||||||
dm_fixup_for_gd_move(new_gd);
|
dm_fixup_for_gd_move(new_gd);
|
||||||
#endif
|
#endif
|
||||||
|
#if CONFIG_IS_ENABLED(LOG)
|
||||||
|
log_fixup_for_gd_move(new_gd);
|
||||||
|
#endif
|
||||||
#if !defined(CONFIG_ARM) && !defined(CONFIG_RISCV)
|
#if !defined(CONFIG_ARM) && !defined(CONFIG_RISCV)
|
||||||
gd = new_gd;
|
gd = new_gd;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -688,4 +688,16 @@ static inline int log_get_default_format(void)
|
||||||
(IS_ENABLED(CONFIG_LOGF_FUNC) ? BIT(LOGF_FUNC) : 0);
|
(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
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue