Re: [PATCH v2 2/2] RISC-V: Consolidate isa correctness check

From: Paul Walmsley
Date: Fri Oct 18 2019 - 14:25:24 EST


On Fri, 18 Oct 2019, Atish Patra wrote:

> On Fri, 2019-10-18 at 01:43 -0700, Paul Walmsley wrote:
> > On Wed, 9 Oct 2019, Atish Patra wrote:
> >
> > > Currently, isa string is read and checked for correctness at
> > > multiple places.
> > >
> > > Consolidate them into one function and use it only during early
> > > bootup. In case of a incorrect isa string, the cpu shouldn't boot at
> > > all.
> > >
> > > Signed-off-by: Atish Patra <atish.patra@xxxxxxx>
> >
> > Looks like riscv_read_check_isa() is called twice for each hart. Is
> > there any way to call it only once per hart?
> >
>
> I had to add the check in riscv_fill_hwcap() because that function is
> iterating over all cpu nodes to set the hwcap. Thus, some of the harts
> that are not available due to incorrect isa string can affect hwcap.
>
> We can check cpu_possible_mask to figure out the harts with invalid isa
> strings but that will perform poorly as RISC-V have more harts in
> future.

How about just calling riscv_read_check_isa() once for all harts and
leaving riscv_fill_hwcap() the way it was? You'll probably need to hoist
the earlier call out of setup_smp(), so it still is called when
!CONFIG_SMP.


- Paul