[rtems commit] bsps: Add CLOCK_DRIVER_USE_ONLY_BOOT_PROCESSOR

Sebastian Huber sebh at rtems.org
Tue Jun 14 10:10:08 UTC 2016


Module:    rtems
Branch:    master
Commit:    b61d5cac7c5f1ba801a8d0f896313b2e5cd01111
Changeset: http://git.rtems.org/rtems/commit/?id=b61d5cac7c5f1ba801a8d0f896313b2e5cd01111

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Jun 14 10:56:09 2016 +0200

bsps: Add CLOCK_DRIVER_USE_ONLY_BOOT_PROCESSOR

Add CLOCK_DRIVER_USE_ONLY_BOOT_PROCESSOR clock driver option.  If
defined, then do the clock tick processing on the boot processor on
behalf of all other processors.  Currently, this is intended as a
workaround for a Qemu shortcoming on ARM.

Update #2737.

---

 c/src/lib/libbsp/arm/realview-pbx-a9/configure.ac  |  5 ++++
 .../libbsp/arm/shared/arm-a9mpcore-clock-config.c  |  4 +--
 c/src/lib/libbsp/shared/clockdrv_shell.h           | 29 ++++++++++++++++++----
 3 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/c/src/lib/libbsp/arm/realview-pbx-a9/configure.ac b/c/src/lib/libbsp/arm/realview-pbx-a9/configure.ac
index f26f726..5b64184 100644
--- a/c/src/lib/libbsp/arm/realview-pbx-a9/configure.ac
+++ b/c/src/lib/libbsp/arm/realview-pbx-a9/configure.ac
@@ -41,6 +41,11 @@ RTEMS_BSPOPTS_HELP([CLOCK_DRIVER_USE_FAST_IDLE],
 occurs while the IDLE thread is executing.  This can significantly reduce
 simulation times.])
 
+RTEMS_BSPOPTS_SET([CLOCK_DRIVER_USE_ONLY_BOOT_PROCESSOR],[*qemu*],[1])
+RTEMS_BSPOPTS_HELP([CLOCK_DRIVER_USE_ONLY_BOOT_PROCESSOR],
+[If defined, then do the clock tick processing on the boot processor on behalf
+of all other processors.])
+
 RTEMS_CHECK_SMP
 AM_CONDITIONAL(HAS_SMP,[test "$rtems_cv_HAS_SMP" = "yes"])
 
diff --git a/c/src/lib/libbsp/arm/shared/arm-a9mpcore-clock-config.c b/c/src/lib/libbsp/arm/shared/arm-a9mpcore-clock-config.c
index 3dcf708..63a3dd7 100644
--- a/c/src/lib/libbsp/arm/shared/arm-a9mpcore-clock-config.c
+++ b/c/src/lib/libbsp/arm/shared/arm-a9mpcore-clock-config.c
@@ -94,7 +94,7 @@ static void a9mpcore_clock_gt_init(
     | A9MPCORE_GT_CTRL_TMR_EN;
 }
 
-#ifdef RTEMS_SMP
+#if defined(RTEMS_SMP) && !defined(CLOCK_DRIVER_USE_ONLY_BOOT_PROCESSOR)
 typedef struct {
   uint64_t cmpval;
   uint32_t interval;
@@ -116,7 +116,7 @@ static void a9mpcore_clock_secondary_initialization(
   uint32_t interval
 )
 {
-#ifdef RTEMS_SMP
+#if defined(RTEMS_SMP) && !defined(CLOCK_DRIVER_USE_ONLY_BOOT_PROCESSOR)
   a9mpcore_clock_init_data init_data = {
     .cmpval = cmpval,
     .interval = interval
diff --git a/c/src/lib/libbsp/shared/clockdrv_shell.h b/c/src/lib/libbsp/shared/clockdrv_shell.h
index af03861..6609f5e 100644
--- a/c/src/lib/libbsp/shared/clockdrv_shell.h
+++ b/c/src/lib/libbsp/shared/clockdrv_shell.h
@@ -21,6 +21,7 @@
 #include <rtems/clockdrv.h>
 #include <rtems/score/percpu.h>
 #include <rtems/score/smpimpl.h>
+#include <rtems/score/watchdogimpl.h>
 
 #ifdef Clock_driver_nanoseconds_since_last_tick
 #error "Update driver to use the timecounter instead of nanoseconds extension"
@@ -64,11 +65,29 @@
  * instead of the default.
  */
 #ifndef Clock_driver_timecounter_tick
-  #ifdef CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
-    #define Clock_driver_timecounter_tick() rtems_clock_tick()
-  #else
-    #define Clock_driver_timecounter_tick() rtems_timecounter_tick()
-  #endif
+static void Clock_driver_timecounter_tick( void )
+{
+#if defined(CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER)
+  rtems_clock_tick();
+#elif defined(RTEMS_SMP) && defined(CLOCK_DRIVER_USE_ONLY_BOOT_PROCESSOR)
+  uint32_t cpu_count = _SMP_Get_processor_count();
+  uint32_t cpu_index;
+
+  for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
+    Per_CPU_Control *cpu;
+
+    cpu = _Per_CPU_Get_by_index( cpu_index );
+
+    if ( _Per_CPU_Is_boot_processor( cpu ) ) {
+      rtems_timecounter_tick();
+    } else if ( _Processor_mask_Is_set( _SMP_Online_processors, cpu_index ) ) {
+      _Watchdog_Tick( cpu );
+    }
+  }
+#else
+  rtems_timecounter_tick();
+#endif
+}
 #endif
 
 /**



More information about the vc mailing list