[rtems commit] bsps: Always install IPI in SMP configs

Sebastian Huber sebh at rtems.org
Mon Aug 31 14:21:33 UTC 2020


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Aug 31 14:12:14 2020 +0200

bsps: Always install IPI in SMP configs

The inter-processor interrupt (IPI) may be used to process per-CPU jobs.
See for example the blocked handler in T_interrupt_test().

Update #3199.

---

 bsps/powerpc/qoriq/start/bspsmp.c  | 30 ++++++++++++++----------------
 bsps/riscv/griscv/start/bspsmp.c   | 21 +++++++++------------
 bsps/sparc/leon3/start/bspsmp.c    |  6 ++----
 bsps/sparc/shared/irq/irq-shared.c | 14 ++++----------
 4 files changed, 29 insertions(+), 42 deletions(-)

diff --git a/bsps/powerpc/qoriq/start/bspsmp.c b/bsps/powerpc/qoriq/start/bspsmp.c
index b5a2686..f9da7dd 100644
--- a/bsps/powerpc/qoriq/start/bspsmp.c
+++ b/bsps/powerpc/qoriq/start/bspsmp.c
@@ -210,24 +210,22 @@ bool _CPU_SMP_Start_processor(uint32_t cpu_index)
 
 void _CPU_SMP_Finalize_initialization(uint32_t cpu_count)
 {
-#ifdef QORIQ_IS_HYPERVISOR_GUEST
-  (void) cpu_count;
-#else
-  if (cpu_count > 1) {
-    rtems_status_code sc;
-
-    sc = rtems_interrupt_handler_install(
-      QORIQ_IRQ_IPI_0 + IPI_INDEX,
-      "IPI",
-      RTEMS_INTERRUPT_UNIQUE,
-      bsp_inter_processor_interrupt,
-      NULL
-    );
-    if (sc != RTEMS_SUCCESSFUL) {
-      bsp_fatal(QORIQ_FATAL_SMP_IPI_HANDLER_INSTALL);
-    }
+#ifndef QORIQ_IS_HYPERVISOR_GUEST
+  rtems_status_code sc;
+
+  sc = rtems_interrupt_handler_install(
+    QORIQ_IRQ_IPI_0 + IPI_INDEX,
+    "IPI",
+    RTEMS_INTERRUPT_UNIQUE,
+    bsp_inter_processor_interrupt,
+    NULL
+  );
+  if (sc != RTEMS_SUCCESSFUL) {
+    bsp_fatal(QORIQ_FATAL_SMP_IPI_HANDLER_INSTALL);
   }
 #endif
+
+  (void) cpu_count;
 }
 
 void _CPU_SMP_Prepare_start_multitasking(void)
diff --git a/bsps/riscv/griscv/start/bspsmp.c b/bsps/riscv/griscv/start/bspsmp.c
index df826f8..0e5fd99 100644
--- a/bsps/riscv/griscv/start/bspsmp.c
+++ b/bsps/riscv/griscv/start/bspsmp.c
@@ -55,18 +55,15 @@ void bsp_start_on_secondary_processor(Per_CPU_Control *cpu_self)
 
 uint32_t _CPU_SMP_Initialize(void)
 {
-  if ( rtems_configuration_get_maximum_processors() > 1 ) {
-    GRLIB_Cpu_Unmask_interrupt(GRLIB_mp_irq, _CPU_SMP_Get_current_processor());
-
-    rtems_interrupt_handler_install(
-      GRLIB_mp_irq,
-      "IPI",
-      RTEMS_INTERRUPT_SHARED,
-      bsp_inter_processor_interrupt,
-      NULL
-    );
-
-  }
+  GRLIB_Cpu_Unmask_interrupt(GRLIB_mp_irq, _CPU_SMP_Get_current_processor());
+
+  rtems_interrupt_handler_install(
+    GRLIB_mp_irq,
+    "IPI",
+    RTEMS_INTERRUPT_SHARED,
+    bsp_inter_processor_interrupt,
+    NULL
+  );
 
   return grlib_get_cpu_count(GRLIB_IrqCtrl_Regs);
 }
diff --git a/bsps/sparc/leon3/start/bspsmp.c b/bsps/sparc/leon3/start/bspsmp.c
index caf0200..ba41a1f 100644
--- a/bsps/sparc/leon3/start/bspsmp.c
+++ b/bsps/sparc/leon3/start/bspsmp.c
@@ -60,10 +60,8 @@ uint32_t _CPU_SMP_Initialize( void )
   if ( !leon3_data_cache_snooping_enabled() )
     bsp_fatal( LEON3_FATAL_INVALID_CACHE_CONFIG_MAIN_PROCESSOR );
 
-  if ( rtems_configuration_get_maximum_processors() > 1 ) {
-    LEON_Unmask_interrupt(LEON3_mp_irq);
-    set_vector(bsp_inter_processor_interrupt, LEON_TRAP_TYPE(LEON3_mp_irq), 1);
-  }
+  LEON_Unmask_interrupt(LEON3_mp_irq);
+  set_vector(bsp_inter_processor_interrupt, LEON_TRAP_TYPE(LEON3_mp_irq), 1);
 
   return leon3_get_cpu_count(LEON3_IrqCtrl_Regs);
 }
diff --git a/bsps/sparc/shared/irq/irq-shared.c b/bsps/sparc/shared/irq/irq-shared.c
index 344ed71a..e0ac7d7 100644
--- a/bsps/sparc/shared/irq/irq-shared.c
+++ b/bsps/sparc/shared/irq/irq-shared.c
@@ -45,16 +45,10 @@ void BSP_shared_interrupt_init(void)
   int i;
 
   for (i=0; i <= BSP_INTERRUPT_VECTOR_MAX_STD; i++) {
-#if defined(LEON3) && \
-    (defined(RTEMS_SMP) || defined(RTEMS_MULTIPROCESSING))
-    /* Don't install IRQ handler on IPI interrupt. An SMP kernel with max one
-     * CPU does not use IPIs
-     */
-#ifdef RTEMS_SMP
-    if (rtems_configuration_get_maximum_processors() > 1)
-#endif
-      if (i == LEON3_mp_irq)
-        continue;
+#if defined(LEON3) && (defined(RTEMS_SMP) || defined(RTEMS_MULTIPROCESSING))
+    /* Don't install IRQ handler on IPI interrupt */
+    if (i == LEON3_mp_irq)
+      continue;
 #endif
     vector = SPARC_ASYNCHRONOUS_TRAP(i) + 0x10;
     rtems_interrupt_catch(bsp_isr_handler, vector, &previous_isr);



More information about the vc mailing list