From 8a6de83fd833c4b0458ba27eb4883c53c1b1ecf4 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 17 Feb 2014 10:10:27 +0100 Subject: score: Move _SMP_Request_other_cores_to_shutdown() Move _SMP_Request_other_cores_to_shutdown() invocation from rtems_shutdown_executive() to _Internal_error_Occurred() to allow a proper shutdown on SMP configurations even in the error case. --- cpukit/score/src/smp.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'cpukit/score/src/smp.c') diff --git a/cpukit/score/src/smp.c b/cpukit/score/src/smp.c index df1c6d312a..50ebc132a8 100644 --- a/cpukit/score/src/smp.c +++ b/cpukit/score/src/smp.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #if defined(RTEMS_DEBUG) #include @@ -137,17 +137,23 @@ void _SMP_Request_other_cores_to_perform_first_context_switch( void ) void _SMP_Request_other_cores_to_shutdown( void ) { uint32_t self = _SMP_Get_current_processor(); - uint32_t ncpus = _SMP_Get_processor_count(); - uint32_t cpu; - _SMP_Broadcast_message( RTEMS_BSP_SMP_SHUTDOWN ); + /* + * Do not use _SMP_Get_processor_count() since this value might be not + * initialized yet. For example due to a fatal error in the middle of + * bsp_smp_initialize(). + */ + uint32_t ncpus = rtems_configuration_get_maximum_processors(); + + uint32_t cpu; for ( cpu = 0 ; cpu < ncpus ; ++cpu ) { if ( cpu != self ) { - _Per_CPU_Wait_for_state( - _Per_CPU_Get_by_index( cpu ), - PER_CPU_STATE_SHUTDOWN - ); + const Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu ); + + if ( per_cpu->state != PER_CPU_STATE_BEFORE_INITIALIZATION ) { + _SMP_Send_message( cpu, RTEMS_BSP_SMP_SHUTDOWN ); + } } } } -- cgit v1.2.3