[PATCH] dm: core: allow DM_POST_INIT_F notification for TIMER_EARLY

Chanho Park chanho61.park at samsung.com
Fri Aug 18 06:40:34 CEST 2023


Hi Simon,

> -----Original Message-----
> From: Simon Glass <sjg at chromium.org>
> Sent: Wednesday, August 9, 2023 2:54 AM
> To: Chanho Park <chanho61.park at samsung.com>
> Cc: u-boot at lists.denx.de; Bin Meng <bmeng.cn at gmail.com>
> Subject: Re: [PATCH] dm: core: allow DM_POST_INIT_F notification for
> TIMER_EARLY
> 
> Hi Chanho,
> 
> On Tue, 8 Aug 2023 at 01:35, Chanho Park <chanho61.park at samsung.com> wrote:
> >
> > Since the Patch 55171aedda88, VisionFive2 booting has been broken [1].
> > VisionFive2 board requires to enable CONFIG_TIMER_EARLY but booting
> > went to panic from initr_dm_devices due to lack of a timer device.
> >
> > - Error logs
> > initcall sequence 00000000fffd8d38 failed at call 00000000402185e4
> > (err=-19)
> >
> > We can reproduce it on Qemu Sifive HiFive Unleashed emulation[2] after
> > enabling CONFIG_TIMER_EARLY manually.
> >
> > [1]:
> > https://protect2.fireeye.com/v1/url?k=38a0f71d-592be204-38a17c52-74fe4
> > 85cbfec-8b0f4f7ae7f889ef&q=1&e=3bf1c52b-7aa0-464a-86d3-ecec3db1395d&u=
> > https%3A%2F%2Flists.denx.de%2Fpipermail%2Fu-boot%2F2023-June%2F521220.
> > html
> > [2]:
> > https://www.qemu.org/docs/master/system/riscv/sifive_u.html#running-u-
> > boot
> > Fixes: 55171aedda88 ("dm: Emit the arch_cpu_init_dm() even only before
> > relocation")
> > Cc: Simon Glass <sjg at chromium.org>
> > Cc: Bin Meng <bmeng.cn at gmail.com>
> > Signed-off-by: Chanho Park <chanho61.park at samsung.com>
> > ---
> >  drivers/core/root.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/core/root.c b/drivers/core/root.c index
> > 6775fb0b6575..e939da484b2a 100644
> > --- a/drivers/core/root.c
> > +++ b/drivers/core/root.c
> > @@ -436,7 +436,8 @@ int dm_init_and_scan(bool pre_reloc_only)
> >                         return ret;
> >                 }
> >         }
> > -       if (CONFIG_IS_ENABLED(DM_EVENT) && !(gd->flags & GD_FLG_RELOC)) {
> > +       if (CONFIG_IS_ENABLED(DM_EVENT) &&
> > +           (!(gd->flags & GD_FLG_RELOC) ||
> > + CONFIG_IS_ENABLED(TIMER_EARLY))) {
> >                 ret = event_notify_null(EVT_DM_POST_INIT_F);
> >                 if (ret)
> >                         return log_msg_ret("ev", ret);
> > --
> > 2.39.2
> >
> 
> It looks like you need a new notification. The correct fix would be to add
> a new EVT_DM_POST_INIT_R event and emit that after relocation, e.g.
> 
> if (CONFIG_IS_ENABLED(DM_EVENT) {
>    ret = event_notify_null(gd->flags & GD_FLG_RELOC ?
>          EVT_DM_POST_INIT_R : EVT_DM_POST_INIT_F);
>    if (ret)
>       return log_msg_ret("ev", ret);
> }

Sorry for this late reply.
I feel like I need to move riscv_cpu_probe call from arch_early_init_r and make it as the callback of the new event.
I'll send v2 with the changes.

Best Regards,
Chanho Park



More information about the U-Boot mailing list