[PATCH v3 1/5] riscv: Add boot hartid to Device tree

Atish Patra atishp at atishpatra.org
Thu Mar 19 21:39:09 CET 2020


On Wed, Mar 18, 2020 at 8:14 PM Bin Meng <bmeng.cn at gmail.com> wrote:
>
> On Thu, Mar 19, 2020 at 11:10 AM Bin Meng <bmeng.cn at gmail.com> wrote:
> >
> > On Wed, Mar 18, 2020 at 5:19 AM Atish Patra <atish.patra at wdc.com> wrote:
> > >
> > > Linux booting protocol mandates that register "a0" contains the hartid.
> > > However, U-boot can not pass the hartid via a0 during via standard UEFI
> >
> > nits: U-Boot
> >
> > remove "during" ?
> >
> > > protocol. DT nodes are commonly used to pass such information to the OS.
> > >
> > > Add a DT node under chosen node to indicate the boot hartid. EFI stub
> > > in Linux kernel will parse this node and pass it to the real kernel
> > > in "a0" before jumping to it.
> > >
> > > Signed-off-by: Atish Patra <atish.patra at wdc.com>
> > > Reviewed-by: Rick Chen <rick at andestech.com>
> > > ---
> > >  arch/riscv/lib/bootm.c | 22 ++++++++++++++++++++++
> > >  1 file changed, 22 insertions(+)
> > >
> > > diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c
> > > index fad16901c5f2..f927694ae32f 100644
> > > --- a/arch/riscv/lib/bootm.c
> > > +++ b/arch/riscv/lib/bootm.c
> > > @@ -28,6 +28,28 @@ __weak void board_quiesce_devices(void)
> > >
> > >  int arch_fixup_fdt(void *blob)
> > >  {
>
> One additional note, do have need to guard the "boot-hartid" fix-up with
>
> #ifdef CONFIG_EFI_LOADER
>
> #endif
>

Good point. Thanks I will add it.

> ?
>
> > > +       u32 size;
> > > +       int chosen_offset, err;
> > > +
> > > +       size = fdt_totalsize(blob);
> > > +       err  = fdt_open_into(blob, blob, size + 32);
> > > +       if (err < 0) {
> > > +               printf("Device Tree can't be expanded to accommodate new node");
> > > +               return -1;
> >
> > return err
> >

Sure.

> > > +       }
> > > +       chosen_offset = fdt_path_offset(blob, "/chosen");
> > > +       if (chosen_offset < 0) {
> > > +               err = fdt_add_subnode(blob, 0, "chosen");
> > > +               if (err < 0) {
> > > +                       printf("chosen node can not be added\n");
> > > +                       return -1;
> >
> > return err
> >

Sure.

> > > +               }
> > > +       }
> > > +
> > > +       /* Overwrite the boot-hartid as U-Boot is the last state BL */
> >
> > typo: stage
> >
> > > +       fdt_setprop_u32(blob, chosen_offset, "boot-hartid",
> > > +                          gd->arch.boot_hart);
> > > +
> > >         return 0;
> > >  }
> > >
> > > --
>
> Regards,
> Bin

I will address all other typos as well.

-- 
Regards,
Atish


More information about the U-Boot mailing list