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

From: Atish Patra
Date: Mon Nov 04 2019 - 18:07:03 EST


On Fri, 2019-10-18 at 11:25 -0700, Paul Walmsley wrote:
> 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.

Currently, it doesn't let boot any cpu with incorrect isa string for
smp usecase. We still need to preserve that usecase. I think
setup_smp() use is unavoidable.

If the boot cpu has incorrect isa info for !CONFIG_SMP, I guess we
should halt the boot with BUG_ON. This is a separate
riscv_read_check_isa call with boot hart device node.

This is what we can do:

Maintain a global cpumask of harts with invalid isa strings which would
be set during early bootup (before setup_smp). This cpumask will be
used in setup_smp() and riscv_fill_hwcap() to avoid using harts with
invalid isa. This will make sure that there is only single invocaiton
of riscv_read_check_isa(). In most cases, this cpumask will be empty
and penalty of cpumask check won't matter.

Is that what you had in mind or any other approach to address all 3
usecases ?

>
> - Paul

--
Regards,
Atish