[U-Boot] [PATCH] dm: core: Fix Handling global_data moving in SPL

Simon Glass sjg at chromium.org
Fri Feb 10 18:38:51 UTC 2017


Hi Lokesh,

On 10 February 2017 at 06:41, Lokesh Vutla <lokeshvutla at 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(). But it is not necessary that spl_init() is not
> always called before board_init_r(). So, uclass_root.next might

Can you reword to drop the double negative?

> not be initialized and accessing uclass_root.next->prev gives
> an abort. Update the uclass_root only if it is available.
>
> Signed-off-by: Lokesh Vutla <lokeshvutla at ti.com>

Reviewed-by: Simon Glass <sjg at chromium.org>

> ---
> - I encountered this problem when trying to enable SPL_DM on AM43xx
>   devices.


Eek - good spotting!

>  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..8d570f3f78 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 (new_gd->uclass_root.next)
> +               new_gd->uclass_root.next->prev = &new_gd->uclass_root;
> +       if (new_gd->uclass_root.prev)
> +               new_gd->uclass_root.prev->next = &new_gd->uclass_root;

Can you use

 if (gd->dm_root) {... }

We will never see prev without next, so what you have is confusing.

>  }
>
>  fdt_addr_t dm_get_translation_offset(void)
> --
> 2.11.0
>

Regards,
Simon


More information about the U-Boot mailing list