[U-Boot] [PATCH] riscv: cpu: Skip unavailable hart in the get_count() op

Rick Chen rickchen36 at gmail.com
Mon Aug 12 09:33:05 UTC 2019


Hi Lukas

> > From: Auer, Lukas [mailto:lukas.auer at aisec.fraunhofer.de]
> > Sent: Thursday, August 08, 2019 10:04 PM
> > To: bmeng.cn at gmail.com
> > Cc: Rick Jian-Zhi Chen(陳建志); u-boot at lists.denx.de
> > Subject: Re: [PATCH] riscv: cpu: Skip unavailable hart in the get_count() op
> >
> > Hi Bin,
> >
> > On Thu, 2019-08-08 at 21:25 +0800, Bin Meng wrote:
> > > Hi Lukas,
> > >
> > > On Thu, Aug 8, 2019 at 7:22 PM Auer, Lukas
> > > <lukas.auer at aisec.fraunhofer.de> wrote:
> > > > Hi Bin,
> > > >
> > > > On Thu, 2019-08-08 at 00:52 -0700, Bin Meng wrote:
> > > > > We should not count in hart that is marked as not available in the
> > > > > device tree in riscv_cpu_get_count().
> > > > >
> > > >
> > > > I think it might make sense to also exclude harts that are not
> > > > listed as available in the available_harts mask. So the same logic
> > > > as in arch/riscv/lib/smp.c. In this case, the bind function should
> > > > probably check the mask as well.
> > > >
> > >
> > > Yes, the check to available_harts mask can be added in
> > > riscv_cpu_get_count(). I will do that.
> > >
> > > However, I doubt we could do available_harts mask check in the bind
> > > function. If it returns error for non-available harts, the whole
> > > initialization process fails.
> > >
> >
> > You are right, I did not think about that. Perhaps it's best to ignore the
> > available_harts mask in the count function as well then.
> >
> > It just checked where cpu_get_count() is used. The Andes PLIC driver
> > (lib/andes_plic.c) uses it in a way that the patch might break the driver. It
> > iterates over all harts, assuming the first hart is 0 and the last hart the result of
> > cpu_get_count(). If any of the harts is set to disabled, this will no longer be
> > true. It's probably best to update the driver to use the
> > ofnode_for_each_subnode() macro to iterate over all harts. Rick, can you
> > update the driver?

Yes, I will prepare a patch to update it.
Thanks for your catch and reminding.

Regards,
Rick

> >
> > Thanks,
> > Lukas
> >
> > > > Looks good otherwise!
> > > >
> > > > Reviewed-by: Lukas Auer <lukas.auer at aisec.fraunhofer.de>
> > > >
> > >
> > > Regards,
> > > Bin


More information about the U-Boot mailing list