[PATCH 34/34] bsp/leon3: Simplify shutdown

Sebastian Huber sebastian.huber at embedded-brains.de
Wed May 31 16:31:09 UTC 2023


Do not wait for other processors to halt.
---
 bsps/sparc/leon3/start/bspclean.c             | 63 +------------------
 .../fatal-bsp-sparc-leon3-shutdown.yml        |  3 +-
 2 files changed, 4 insertions(+), 62 deletions(-)

diff --git a/bsps/sparc/leon3/start/bspclean.c b/bsps/sparc/leon3/start/bspclean.c
index d52eb65ecf..0324c45326 100644
--- a/bsps/sparc/leon3/start/bspclean.c
+++ b/bsps/sparc/leon3/start/bspclean.c
@@ -38,48 +38,6 @@
 #include <rtems/score/cpuimpl.h>
 #include <rtems/score/smpimpl.h>
 
-#if defined(RTEMS_SMP)
-static void leon3_wait_for_power_down(irqamp *regs)
-{
-  uint32_t max_wait;
-  uint32_t cpu_self;
-  uint32_t cpu_count;
-  uint32_t halt_mask;
-  uint32_t i;
-
-  cpu_count = leon3_get_cpu_count(regs);
-
-  if (cpu_count > rtems_configuration_get_maximum_processors()) {
-    cpu_count = rtems_configuration_get_maximum_processors();
-  }
-
-  cpu_self = rtems_scheduler_get_processor();
-  halt_mask = 0;
-
-  for (i = 0; i < cpu_count; ++i) {
-    if (i != cpu_self && _SMP_Should_start_processor(i)) {
-      halt_mask |= UINT32_C(1) << i;
-    }
-  }
-
-  /*
-   * Wait some time for secondary processors to halt.
-   *
-   * The value was chosen to get something in the magnitude of 1ms on a 200MHz
-   * processor.
-   */
-
-  max_wait = 1234567;
-  i = 0;
-
-  while (
-    (grlib_load_32(&regs->mpstat) & halt_mask) != halt_mask && i < max_wait
-  ) {
-    ++i;
-  }
-}
-#endif
-
 void bsp_fatal_extension(
   rtems_fatal_source source,
   bool always_set_to_false,
@@ -92,29 +50,12 @@ void bsp_fatal_extension(
   (void) level;
 
 #if defined(RTEMS_SMP)
-  /*
-   * On SMP we must wait for all other CPUs not requesting a fatal halt, they
-   * are responding to another CPU's fatal request. These CPUs goes into
-   * power-down. The CPU requesting fatal halt waits for the others and then
-   * handles the system shutdown via the normal procedure.
-   */
   if ((source == RTEMS_FATAL_SOURCE_SMP) &&
       (code == SMP_FATAL_SHUTDOWN_RESPONSE)) {
     leon3_power_down_loop(); /* CPU didn't start shutdown sequence .. */
-  } else {
-    irqamp *regs;
-
-    _SMP_Request_shutdown();
-
-    regs = LEON3_IrqCtrl_Regs;
-#if defined(LEON3_IRQAMP_BASE)
-    leon3_wait_for_power_down(regs);
-#else
-    if (regs != NULL) {
-      leon3_wait_for_power_down(regs);
-    }
-#endif
   }
+
+  _SMP_Request_shutdown();
 #endif
 
 #if BSP_PRINT_EXCEPTION_CONTEXT
diff --git a/spec/build/testsuites/validation/fatal-bsp-sparc-leon3-shutdown.yml b/spec/build/testsuites/validation/fatal-bsp-sparc-leon3-shutdown.yml
index fff8a48f9c..2c60605480 100644
--- a/spec/build/testsuites/validation/fatal-bsp-sparc-leon3-shutdown.yml
+++ b/spec/build/testsuites/validation/fatal-bsp-sparc-leon3-shutdown.yml
@@ -11,7 +11,8 @@ enabled-by:
   - bsps/sparc/leon3
 features: c cprogram
 includes: []
-ldflags: []
+ldflags:
+- -Wl,--wrap=_CPU_Fatal_halt
 links: []
 source:
 - testsuites/validation/tc-fatal-bsp-sparc-leon3-shutdown.c
-- 
2.35.3



More information about the devel mailing list