[PATCH 3/3] _SMP_Start_multitasking_on_secondary_processor()

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Jul 24 12:38:07 UTC 2018


Pass current processor control as first parameter to make dependency
more explicit.
---
 bsps/arm/include/bsp/arm-a9mpcore-start.h |  2 +-
 bsps/arm/raspberrypi/start/bspsmp_init.c  |  2 +-
 bsps/i386/pc386/start/smp-imps.c          |  2 +-
 bsps/powerpc/qoriq/start/bspsmp.c         |  2 +-
 bsps/sparc/leon3/start/bspsmp.c           |  2 +-
 cpukit/include/rtems/score/smpimpl.h      |  7 +++++--
 cpukit/score/src/smp.c                    | 26 +++++++++++++++++---------
 7 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/bsps/arm/include/bsp/arm-a9mpcore-start.h b/bsps/arm/include/bsp/arm-a9mpcore-start.h
index dd1e1247de..5648dc0daf 100644
--- a/bsps/arm/include/bsp/arm-a9mpcore-start.h
+++ b/bsps/arm/include/bsp/arm-a9mpcore-start.h
@@ -109,7 +109,7 @@ arm_a9mpcore_start_on_secondary_processor(void)
   ctrl |= ARM_CP15_CTRL_I | ARM_CP15_CTRL_C | ARM_CP15_CTRL_M;
   arm_cp15_set_control(ctrl);
 
-  _SMP_Start_multitasking_on_secondary_processor();
+  _SMP_Start_multitasking_on_secondary_processor(_Per_CPU_Get());
 }
 
 BSP_START_TEXT_SECTION static inline void
diff --git a/bsps/arm/raspberrypi/start/bspsmp_init.c b/bsps/arm/raspberrypi/start/bspsmp_init.c
index 8c8cd74712..a8c79e9f7c 100644
--- a/bsps/arm/raspberrypi/start/bspsmp_init.c
+++ b/bsps/arm/raspberrypi/start/bspsmp_init.c
@@ -77,5 +77,5 @@ void rpi_start_rtems_on_secondary_processor(void)
   ctrl &= ~ARM_CP15_CTRL_V;
   arm_cp15_set_control(ctrl);
 
-  _SMP_Start_multitasking_on_secondary_processor();
+  _SMP_Start_multitasking_on_secondary_processor(_Per_CPU_Get());
 }
diff --git a/bsps/i386/pc386/start/smp-imps.c b/bsps/i386/pc386/start/smp-imps.c
index 405f7f0a92..d8b2dd3edc 100644
--- a/bsps/i386/pc386/start/smp-imps.c
+++ b/bsps/i386/pc386/start/smp-imps.c
@@ -794,7 +794,7 @@ static void secondary_cpu_initialize(void)
   enable_sse();
 #endif
 
-  _SMP_Start_multitasking_on_secondary_processor();
+  _SMP_Start_multitasking_on_secondary_processor( _Per_CPU_Get() );
 }
 
 uint32_t _CPU_SMP_Initialize( void )
diff --git a/bsps/powerpc/qoriq/start/bspsmp.c b/bsps/powerpc/qoriq/start/bspsmp.c
index 2b95f943dd..634d0f89eb 100644
--- a/bsps/powerpc/qoriq/start/bspsmp.c
+++ b/bsps/powerpc/qoriq/start/bspsmp.c
@@ -53,7 +53,7 @@ void qoriq_start_thread(Per_CPU_Control *cpu_self)
 
   bsp_interrupt_facility_initialize();
 
-  _SMP_Start_multitasking_on_secondary_processor();
+  _SMP_Start_multitasking_on_secondary_processor(cpu_self);
 }
 #endif
 
diff --git a/bsps/sparc/leon3/start/bspsmp.c b/bsps/sparc/leon3/start/bspsmp.c
index 5b939fc765..caf0200a3c 100644
--- a/bsps/sparc/leon3/start/bspsmp.c
+++ b/bsps/sparc/leon3/start/bspsmp.c
@@ -52,7 +52,7 @@ void bsp_start_on_secondary_processor(Per_CPU_Control *cpu_self)
   cpu_index_self = _Per_CPU_Get_index(cpu_self);
   LEON3_IrqCtrl_Regs->mask[cpu_index_self] |= 1U << LEON3_mp_irq;
 
-  _SMP_Start_multitasking_on_secondary_processor();
+  _SMP_Start_multitasking_on_secondary_processor(cpu_self);
 }
 
 uint32_t _CPU_SMP_Initialize( void )
diff --git a/cpukit/include/rtems/score/smpimpl.h b/cpukit/include/rtems/score/smpimpl.h
index fd92f655c7..762b3e5fc1 100644
--- a/cpukit/include/rtems/score/smpimpl.h
+++ b/cpukit/include/rtems/score/smpimpl.h
@@ -134,9 +134,12 @@ extern Processor_mask _SMP_Online_processors;
  * uses _Thread_Start_multitasking() instead.
  *
  * This function does not return to the caller.
+ *
+ * @param[in] cpu_self The current processor control.
  */
-void _SMP_Start_multitasking_on_secondary_processor( void )
-  RTEMS_NO_RETURN;
+void _SMP_Start_multitasking_on_secondary_processor(
+  Per_CPU_Control *cpu_self
+) RTEMS_NO_RETURN;
 
 typedef void ( *SMP_Test_message_handler )( Per_CPU_Control *cpu_self );
 
diff --git a/cpukit/score/src/smp.c b/cpukit/score/src/smp.c
index 1a29e37d15..1c7eb6d947 100644
--- a/cpukit/score/src/smp.c
+++ b/cpukit/score/src/smp.c
@@ -145,14 +145,19 @@ void _SMP_Handler_initialize( void )
 
 void _SMP_Request_start_multitasking( void )
 {
-  Per_CPU_Control *self_cpu = _Per_CPU_Get();
-  uint32_t cpu_count = _SMP_Get_processor_count();
-  uint32_t cpu_index;
+  Per_CPU_Control *cpu_self;
+  uint32_t         cpu_count;
+  uint32_t         cpu_index;
+
+  cpu_self = _Per_CPU_Get();
+  _Per_CPU_State_change( cpu_self, PER_CPU_STATE_READY_TO_START_MULTITASKING );
 
-  _Per_CPU_State_change( self_cpu, PER_CPU_STATE_READY_TO_START_MULTITASKING );
+  cpu_count = _SMP_Get_processor_count();
 
   for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
-    Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index );
+    Per_CPU_Control *cpu;
+
+    cpu = _Per_CPU_Get_by_index( cpu_index );
 
     if ( _Per_CPU_Is_processor_online( cpu ) ) {
       _Per_CPU_State_change( cpu, PER_CPU_STATE_REQUEST_START_MULTITASKING );
@@ -168,10 +173,13 @@ bool _SMP_Should_start_processor( uint32_t cpu_index )
   return _Scheduler_Should_start_processor( assignment );
 }
 
-void _SMP_Start_multitasking_on_secondary_processor( void )
+void _SMP_Start_multitasking_on_secondary_processor(
+  Per_CPU_Control *cpu_self
+)
 {
-  Per_CPU_Control *self_cpu = _Per_CPU_Get();
-  uint32_t cpu_index_self = _Per_CPU_Get_index( self_cpu );
+  uint32_t cpu_index_self;
+
+  cpu_index_self = _Per_CPU_Get_index( cpu_self );
 
   if ( cpu_index_self >= rtems_configuration_get_maximum_processors() ) {
     _SMP_Fatal( SMP_FATAL_MULTITASKING_START_ON_INVALID_PROCESSOR );
@@ -181,7 +189,7 @@ void _SMP_Start_multitasking_on_secondary_processor( void )
     _SMP_Fatal( SMP_FATAL_MULTITASKING_START_ON_UNASSIGNED_PROCESSOR );
   }
 
-  _Per_CPU_State_change( self_cpu, PER_CPU_STATE_READY_TO_START_MULTITASKING );
+  _Per_CPU_State_change( cpu_self, PER_CPU_STATE_READY_TO_START_MULTITASKING );
 
   _Thread_Start_multitasking();
 }
-- 
2.13.7




More information about the devel mailing list