[PATCH 08/10] bsps/riscv: bsp_interrupt_get/set_affinity()

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Nov 9 16:09:18 UTC 2022


Provide bsp_interrupt_get_affinity() and bsp_interrupt_set_affinity() only if
RTEMS_SMP is enabled.  Replace fatal error with a status code.
---
 bsps/include/bsp/fatal.h   |  2 +-
 bsps/riscv/riscv/irq/irq.c | 19 ++++++-------------
 2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/bsps/include/bsp/fatal.h b/bsps/include/bsp/fatal.h
index ec8bd68280..a09b8ed6a5 100644
--- a/bsps/include/bsp/fatal.h
+++ b/bsps/include/bsp/fatal.h
@@ -185,7 +185,7 @@ typedef enum {
   RISCV_FATAL_NO_PLIC_REG_IN_DEVICE_TREE,
   RISCV_FATAL_INVALID_PLIC_NDEV_IN_DEVICE_TREE,
   RISCV_FATAL_TOO_LARGE_PLIC_NDEV_IN_DEVICE_TREE,
-  RISCV_FATAL_INVALID_INTERRUPT_AFFINITY,
+  RISCV_FATAL_UNUSED_0,
   RISCV_FATAL_NO_NS16550_INTERRUPTS_IN_DEVICE_TREE,
   RISCV_FATAL_NO_TLCLOCK_FREQUENCY_IN_DEVICE_TREE,
   RISCV_FATAL_CLOCK_SMP_INIT,
diff --git a/bsps/riscv/riscv/irq/irq.c b/bsps/riscv/riscv/irq/irq.c
index 2999485f88..44d0778ec7 100644
--- a/bsps/riscv/riscv/irq/irq.c
+++ b/bsps/riscv/riscv/irq/irq.c
@@ -567,6 +567,7 @@ rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector)
   return RTEMS_SUCCESSFUL;
 }
 
+#ifdef RTEMS_SMP
 rtems_status_code bsp_interrupt_set_affinity(
   rtems_vector_number vector,
   const Processor_mask *affinity
@@ -595,7 +596,7 @@ rtems_status_code bsp_interrupt_set_affinity(
       return RTEMS_SUCCESSFUL;
     }
 
-    bsp_fatal(RISCV_FATAL_INVALID_INTERRUPT_AFFINITY);
+    return RTEMS_INVALID_NUMBER;
   }
 
   return RTEMS_UNSATISFIED;
@@ -606,8 +607,6 @@ rtems_status_code bsp_interrupt_get_affinity(
   Processor_mask *affinity
 )
 {
-  _Processor_mask_Zero(affinity);
-
   if (RISCV_INTERRUPT_VECTOR_IS_EXTERNAL(vector)) {
     uint32_t interrupt_index;
     volatile uint32_t *enable;
@@ -616,7 +615,6 @@ rtems_status_code bsp_interrupt_get_affinity(
     enable = riscv_plic_irq_to_cpu[interrupt_index - 1];
 
     if (enable != NULL) {
-#ifdef RTEMS_SMP
       uint32_t cpu_max;
       uint32_t cpu_index;
 
@@ -632,18 +630,13 @@ rtems_status_code bsp_interrupt_get_affinity(
           break;
         }
       }
-#else
-      Per_CPU_Control *cpu;
-
-      cpu = _Per_CPU_Get_by_index(0);
-
-      if (enable == cpu->cpu_per_cpu.plic_m_ie)
-        _Processor_mask_Set(affinity, 0);
-#endif
     } else {
       _Processor_mask_Assign(affinity, _SMP_Get_online_processors());
     }
+
+    return RTEMS_SUCCESSFUL;
   }
 
-  return RTEMS_SUCCESSFUL;
+  return RTEMS_UNSATISFIED;
 }
+#endif
-- 
2.35.3



More information about the devel mailing list