diff mbox

[U-Boot,v2] dm: core: Fix Handling of global_data moving in SPL

Message ID 20170213035122.1006-1-lokeshvutla@ti.com
State Accepted
Commit d666558042a0272de3f38607ce15088e0d4c88b0
Delegated to: Simon Glass
Headers show

Commit Message

Lokesh Vutla Feb. 13, 2017, 3:51 a.m. UTC
commit 2f11cd9121658 ("dm: core: Handle global_data moving in SPL")
handles relocation of GD in SPL if spl_init() is called before
board_init_r(). So, uclass_root.next need not be initialized always
and accessing uclass_root.next->prev gives an abort. Update the
uclass_root only if it is available.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 drivers/core/root.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Simon Glass March 17, 2017, 4:19 p.m. UTC | #1
On 12 February 2017 at 20:51, Lokesh Vutla <lokeshvutla@ti.com> wrote:
> commit 2f11cd9121658 ("dm: core: Handle global_data moving in SPL")
> handles relocation of GD in SPL if spl_init() is called before
> board_init_r(). So, uclass_root.next need not be initialized always
> and accessing uclass_root.next->prev gives an abort. Update the
> uclass_root only if it is available.
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
> ---
>  drivers/core/root.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/core/root.c b/drivers/core/root.c
> index 9edfc1efb6..4c935f40b6 100644
> --- a/drivers/core/root.c
> +++ b/drivers/core/root.c
> @@ -44,8 +44,10 @@ struct udevice *dm_root(void)
>  void dm_fixup_for_gd_move(struct global_data *new_gd)
>  {
>         /* The sentinel node has moved, so update things that point to it */
> -       new_gd->uclass_root.next->prev = &new_gd->uclass_root;
> -       new_gd->uclass_root.prev->next = &new_gd->uclass_root;
> +       if (gd->dm_root) {
> +               new_gd->uclass_root.next->prev = &new_gd->uclass_root;
> +               new_gd->uclass_root.prev->next = &new_gd->uclass_root;
> +       }
>  }
>
>  fdt_addr_t dm_get_translation_offset(void)
> --
> 2.11.0
>

Applied to u-boot-dm, thanks!
diff mbox

Patch

diff --git a/drivers/core/root.c b/drivers/core/root.c
index 9edfc1efb6..4c935f40b6 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -44,8 +44,10 @@  struct udevice *dm_root(void)
 void dm_fixup_for_gd_move(struct global_data *new_gd)
 {
 	/* The sentinel node has moved, so update things that point to it */
-	new_gd->uclass_root.next->prev = &new_gd->uclass_root;
-	new_gd->uclass_root.prev->next = &new_gd->uclass_root;
+	if (gd->dm_root) {
+		new_gd->uclass_root.next->prev = &new_gd->uclass_root;
+		new_gd->uclass_root.prev->next = &new_gd->uclass_root;
+	}
 }
 
 fdt_addr_t dm_get_translation_offset(void)