[PATCH 1/3] bsps/riscv: Make SMP start more robust
Alan Cudmore
alan.cudmore at gmail.com
Thu Mar 16 21:33:17 UTC 2023
Hi Sebastian,
I applied these three patches after my patches and ran them on my K210
board and simulator. I have a set of 12 tests including benchmarks, SMP01,
SMP08, ticker, etc. Everything ran OK.
Is there anything in particular I can try to test them like setting the
maximum CPUs to 1? (K210 is a dual core)
Alan
On Thu, Mar 16, 2023 at 4:59 AM Sebastian Huber <
sebastian.huber at embedded-brains.de> wrote:
> In SMP configurations, check that we run on a configured processor. If
> not,
> then there is not much what can be done since we do not have a stack
> available
> for this processor. Just loop forever in this case. Do this in assemlby
> to
> ensure that no stack memory is used.
> ---
> bsps/riscv/riscv/start/bspsmp.c | 5 +----
> bsps/riscv/shared/start/start.S | 16 ++++++++++++++--
> 2 files changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/bsps/riscv/riscv/start/bspsmp.c
> b/bsps/riscv/riscv/start/bspsmp.c
> index 91f4f7b96a..ce5792f5b8 100644
> --- a/bsps/riscv/riscv/start/bspsmp.c
> +++ b/bsps/riscv/riscv/start/bspsmp.c
> @@ -36,10 +36,7 @@ void bsp_start_on_secondary_processor(Per_CPU_Control
> *cpu_self)
>
> cpu_index_self = _Per_CPU_Get_index(cpu_self);
>
> - if (
> - cpu_index_self < rtems_configuration_get_maximum_processors()
> - && _SMP_Should_start_processor(cpu_index_self)
> - ) {
> + if (_SMP_Should_start_processor(cpu_index_self)) {
> set_csr(mie, MIP_MSIP | MIP_MEIP);
> _SMP_Start_multitasking_on_secondary_processor(cpu_self);
> } else {
> diff --git a/bsps/riscv/shared/start/start.S
> b/bsps/riscv/shared/start/start.S
> index 34e1839ca1..42e4348cd0 100644
> --- a/bsps/riscv/shared/start/start.S
> +++ b/bsps/riscv/shared/start/start.S
> @@ -66,8 +66,17 @@ SYM(_start):
> LADDR sp, _ISR_Stack_area_begin
> LADDR t2, _ISR_Stack_size
> csrr s0, mhartid
> - li t3, RISCV_BOOT_HARTID
> - sub s0, s0, t3
> + li t3, RISCV_BOOT_HARTID
> + sub s0, s0, t3
> +
> + /*
> + * Check that this is a configured processor. If not, then there
> is
> + * not much what can be done since we do not have a stack
> available for
> + * this processor. Just loop forever in this case.
> + */
> + LREG t3, _SMP_Processor_configured_maximum
> + bgeu s0, t3, .Lwfi
> +
> LADDR t0, _Per_CPU_Information
> slli t1, s0, PER_CPU_CONTROL_SIZE_LOG2
> add s1, t0, t1
> @@ -100,6 +109,9 @@ SYM(_start):
> tail boot_card
>
> #ifdef RTEMS_SMP
> +.Lwfi:
> + wfi
> + j .Lwfi
>
> .Lstart_on_secondary_processor:
>
> --
> 2.35.3
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20230316/832f57cc/attachment-0001.htm>
More information about the devel
mailing list