On 02/22/2014 11:02 PM, Chris Johns wrote:
On 19/02/2014 7:52 pm, Sebastian Huber wrote:
Module:    rtems
Branch:    master
Commit:    282bfd3b41e3725ac9f5fb08b1e391af02572f4f
Changeset: http://git.rtems.org/rtems/commit/?id=282bfd3b41e3725ac9f5fb08b1e391af02572f4f

Author:    Sebastian Huber <sebastian.hu...@embedded-brains.de>
Date:      Tue Feb 18 13:03:27 2014 +0100

score: Move _SMP_Handler_initialize()

---

  cpukit/score/src/percpu.c |   31 -------------------------------
  cpukit/score/src/smp.c    |   22 ++++++++++++++++++++++
  2 files changed, 22 insertions(+), 31 deletions(-)

diff --git a/cpukit/score/src/percpu.c b/cpukit/score/src/percpu.c
index aa95aa9..c68f378 100644
--- a/cpukit/score/src/percpu.c
+++ b/cpukit/score/src/percpu.c
@@ -18,40 +18,9 @@
  #include "config.h"
  #endif

-#include <rtems/system.h>
-#include <rtems/score/address.h>
-#include <rtems/score/thread.h>
  #include <rtems/score/percpu.h>
-#include <rtems/score/wkspace.h>
-#include <rtems/config.h>
-#include <string.h>

  #if defined(RTEMS_SMP)
-
-  #include <rtems/score/smp.h>
-
-  void _SMP_Handler_initialize(void)
-  {
-    uint32_t max_cpus = rtems_configuration_get_maximum_processors();
-    uint32_t cpu;
-
-    /*
-     * Discover and initialize the secondary cores in an SMP system.
-     */
-    max_cpus = _CPU_SMP_Initialize( max_cpus );
-
-    _SMP_Processor_count = max_cpus;
-
-    for ( cpu = 1 ; cpu < max_cpus; ++cpu ) {
-      const Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu );
-
-      _Per_CPU_Wait_for_state(
-        per_cpu,
-        PER_CPU_STATE_READY_TO_BEGIN_MULTITASKING
-      );
-    }
-  }
-
    void _Per_CPU_Change_state(
      Per_CPU_Control *per_cpu,
      Per_CPU_State new_state
diff --git a/cpukit/score/src/smp.c b/cpukit/score/src/smp.c
index 86116da..bfd77dc 100644
--- a/cpukit/score/src/smp.c
+++ b/cpukit/score/src/smp.c
@@ -29,6 +29,28 @@
    #include <rtems/bspIo.h>
  #endif

+void _SMP_Handler_initialize( void )
+{
+  uint32_t max_cpus = rtems_configuration_get_maximum_processors();
+  uint32_t cpu;
+
+  /*
+   * Discover and initialize the secondary cores in an SMP system.
+   */
+  max_cpus = _CPU_SMP_Initialize( max_cpus );
+
+  _SMP_Processor_count = max_cpus;
+
+  for ( cpu = 1 ; cpu < max_cpus; ++cpu ) {
+    const Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu );
+
+    _Per_CPU_Wait_for_state(
+      per_cpu,
+      PER_CPU_STATE_READY_TO_BEGIN_MULTITASKING
+    );
+  }
+}

I do not agree with this approach. All cores need to be present before continuing and it forces cpu 0 to be a "boot" or "primary" processor. This design is not symmetric.

I cannot say much more to this topic than that what I wrote here:

http://www.rtems.org/pipermail/rtems-devel/2014-February/005481.html

Yes, this boot processor index == 0 is a problem. One fundamental problem is that exactly one processor must initialize the BSS section. How can you enforce this in general?

The situation in this patch is a bit better:

http://www.rtems.org/pipermail/rtems-devel/2014-February/005465.html

-void _SMP_Start_multitasking_on_secondary_processor( void )
+void _SMP_Request_start_multitasking( void )
 {
   Per_CPU_Control *self_cpu = _Per_CPU_Get();
+  uint32_t ncpus = _SMP_Get_processor_count();
+  uint32_t cpu;
+
+  _Per_CPU_State_change( self_cpu, PER_CPU_STATE_READY_TO_START_MULTITASKING );
- #if defined(RTEMS_DEBUG)
-    printk( "Made it to %d -- ", _Per_CPU_Get_index( self_cpu ) );
-  #endif
+  for ( cpu = 0 ; cpu < ncpus ; ++cpu ) {
+    Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu );
+
+    _Per_CPU_State_change( per_cpu, PER_CPU_STATE_REQUEST_START_MULTITASKING );
+  }
+}

Please notice that this loop starts with cpu = 0.

At the moment I can offer only this patch. It is an improvement since now the shutdown works. There are so many problems and things to do on SMP so that I have to focus. I cannot fix everything at once and now.

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

_______________________________________________
rtems-devel mailing list
rtems-devel@rtems.org
http://www.rtems.org/mailman/listinfo/rtems-devel

Reply via email to