summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2019-04-18 06:47:01 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2019-05-20 08:49:39 +0200
commit658700449de9d67d8571b707eec50c06fdfb9455 (patch)
tree3c2c502dab87383f390f185ca7aeb920e0563b7d
parentsmptests: Move SMP broadcast action test case (diff)
downloadrtems-658700449de9d67d8571b707eec50c06fdfb9455.tar.bz2
score: Add _SMP_Broadcast_action()
-rw-r--r--bsps/arm/shared/clock/clock-a9mpcore.c2
-rw-r--r--bsps/arm/shared/clock/clock-generic-timer.c2
-rw-r--r--bsps/shared/cache/cacheimpl.h4
-rw-r--r--cpukit/include/rtems/score/smpimpl.h24
-rw-r--r--cpukit/score/src/smpmulticastaction.c12
-rw-r--r--testsuites/smptests/smpmulticast01/init.c40
6 files changed, 64 insertions, 20 deletions
diff --git a/bsps/arm/shared/clock/clock-a9mpcore.c b/bsps/arm/shared/clock/clock-a9mpcore.c
index 2907dff800..7dac8445f2 100644
--- a/bsps/arm/shared/clock/clock-a9mpcore.c
+++ b/bsps/arm/shared/clock/clock-a9mpcore.c
@@ -124,7 +124,7 @@ static void a9mpcore_clock_secondary_initialization(
.interval = interval
};
- _SMP_Multicast_action(NULL, a9mpcore_clock_secondary_action, &init_data);
+ _SMP_Broadcast_action(a9mpcore_clock_secondary_action, &init_data);
if (cmpval - a9mpcore_clock_get_counter(gt) >= interval) {
bsp_fatal(BSP_ARM_A9MPCORE_FATAL_CLOCK_SMP_INIT);
diff --git a/bsps/arm/shared/clock/clock-generic-timer.c b/bsps/arm/shared/clock/clock-generic-timer.c
index e851e02104..88fb1967e5 100644
--- a/bsps/arm/shared/clock/clock-generic-timer.c
+++ b/bsps/arm/shared/clock/clock-generic-timer.c
@@ -135,7 +135,7 @@ static void arm_gt_clock_secondary_action(void *arg)
static void arm_gt_clock_secondary_initialization(uint64_t cval)
{
#if defined(RTEMS_SMP) && !defined(CLOCK_DRIVER_USE_ONLY_BOOT_PROCESSOR)
- _SMP_Multicast_action(NULL, arm_gt_clock_secondary_action, &cval);
+ _SMP_Broadcast_action(arm_gt_clock_secondary_action, &cval);
#endif
}
diff --git a/bsps/shared/cache/cacheimpl.h b/bsps/shared/cache/cacheimpl.h
index dbed9c8a19..a91230d22a 100644
--- a/bsps/shared/cache/cacheimpl.h
+++ b/bsps/shared/cache/cacheimpl.h
@@ -329,7 +329,7 @@ rtems_cache_invalidate_multiple_instruction_lines(
#if defined(RTEMS_SMP) && defined(CPU_CACHE_NO_INSTRUCTION_CACHE_SNOOPING)
smp_cache_area area = { i_addr, n_bytes };
- _SMP_Multicast_action( NULL, smp_cache_inst_inv, &area );
+ _SMP_Broadcast_action( smp_cache_inst_inv, &area );
#else
_CPU_cache_invalidate_instruction_range( i_addr, n_bytes );
#endif
@@ -345,7 +345,7 @@ rtems_cache_invalidate_entire_instruction( void )
{
#if defined(CPU_INSTRUCTION_CACHE_ALIGNMENT)
#if defined(RTEMS_SMP) && defined(CPU_CACHE_NO_INSTRUCTION_CACHE_SNOOPING)
- _SMP_Multicast_action( NULL, smp_cache_inst_inv_all, NULL );
+ _SMP_Broadcast_action( smp_cache_inst_inv_all, NULL );
#else
_CPU_cache_invalidate_entire_instruction();
#endif
diff --git a/cpukit/include/rtems/score/smpimpl.h b/cpukit/include/rtems/score/smpimpl.h
index 6dde8f595d..bc24f828fe 100644
--- a/cpukit/include/rtems/score/smpimpl.h
+++ b/cpukit/include/rtems/score/smpimpl.h
@@ -253,12 +253,13 @@ void _SMP_Send_message_multicast(
typedef void ( *SMP_Action_handler )( void *arg );
/**
- * @brief Initiates an SMP multicast action to a set of target processors.
+ * @brief Initiates an SMP multicast action to the set of target processors.
*
- * The current processor may be part of the set.
+ * The current processor may be part of the set. In case a target processor is
+ * in a wrong state to process per-processor jobs, then this function results
+ * in an SMP_FATAL_WRONG_CPU_STATE_TO_PERFORM_JOBS fatal SMP error.
*
- * @param targets The set of target processors for the action. If @c NULL,
- * then the action will be performed on all online processors.
+ * @param targets The set of target processors for the action.
* @param handler The multicast action handler.
* @param arg The multicast action argument.
*/
@@ -268,6 +269,21 @@ void _SMP_Multicast_action(
void *arg
);
+/**
+ * @brief Initiates an SMP multicast action to the set of all online
+ * processors.
+ *
+ * Simply calls _SMP_Multicast_action() with _SMP_Get_online_processors() as
+ * the target processor set.
+ *
+ * @param handler The multicast action handler.
+ * @param arg The multicast action argument.
+ */
+void _SMP_Broadcast_action(
+ SMP_Action_handler handler,
+ void *arg
+);
+
#endif /* defined( RTEMS_SMP ) */
/**
diff --git a/cpukit/score/src/smpmulticastaction.c b/cpukit/score/src/smpmulticastaction.c
index ea430e8e7c..b703ba14a7 100644
--- a/cpukit/score/src/smpmulticastaction.c
+++ b/cpukit/score/src/smpmulticastaction.c
@@ -233,10 +233,6 @@ void _SMP_Multicast_action(
cpu_max = _SMP_Get_processor_maximum();
_Assert( cpu_max <= CPU_MAXIMUM_PROCESSORS );
- if ( targets == NULL ) {
- targets = _SMP_Get_online_processors();
- }
-
jobs.handler = handler;
jobs.arg = arg;
isr_level = _ISR_Get_level();
@@ -254,3 +250,11 @@ void _SMP_Multicast_action(
_Thread_Dispatch_enable( cpu_self );
}
}
+
+void _SMP_Broadcast_action(
+ SMP_Action_handler handler,
+ void *arg
+)
+{
+ _SMP_Multicast_action( _SMP_Get_online_processors(), handler, arg );
+}
diff --git a/testsuites/smptests/smpmulticast01/init.c b/testsuites/smptests/smpmulticast01/init.c
index a5ed85c3ef..7b2556d5e9 100644
--- a/testsuites/smptests/smpmulticast01/init.c
+++ b/testsuites/smptests/smpmulticast01/init.c
@@ -85,6 +85,30 @@ static void multicast_action_dispatch_disabled(
_Thread_Dispatch_enable(cpu_self);
}
+static void broadcast_action_irq_disabled(
+ SMP_Action_handler handler,
+ void *arg
+)
+{
+ rtems_interrupt_level level;
+
+ rtems_interrupt_local_disable(level);
+ _SMP_Broadcast_action(handler, arg);
+ rtems_interrupt_local_enable(level);
+}
+
+static void broadcast_action_dispatch_disabled(
+ SMP_Action_handler handler,
+ void *arg
+)
+{
+ Per_CPU_Control *cpu_self;
+
+ cpu_self = _Thread_Dispatch_disable();
+ _SMP_Broadcast_action(handler, arg);
+ _Thread_Dispatch_enable(cpu_self);
+}
+
static void action(void *arg)
{
Atomic_Uint *id;
@@ -147,7 +171,7 @@ static void test_unicast(
static void test_broadcast(
test_context *ctx,
- void (*multicast_action)(const Processor_mask *, SMP_Action_handler, void *)
+ void (*broadcast_action)(SMP_Action_handler, void *)
)
{
uint32_t step;
@@ -163,7 +187,7 @@ static void test_broadcast(
clear_ids_by_worker(ctx, 0);
- (*multicast_action)(NULL, action, &ctx->id[0][0]);
+ (*broadcast_action)(action, &ctx->id[0][0]);
for (j = 0; j < n; ++j) {
unsigned id;
@@ -255,15 +279,15 @@ static void test_before_multitasking(void)
T_case_end();
T_case_begin("BroadcastBeforeMultitasking", NULL);
- test_broadcast(ctx, _SMP_Multicast_action);
+ test_broadcast(ctx, _SMP_Broadcast_action);
T_case_end();
T_case_begin("BroadcastBeforeMultitaskingIRQDisabled", NULL);
- test_broadcast(ctx, multicast_action_irq_disabled);
+ test_broadcast(ctx, broadcast_action_irq_disabled);
T_case_end();
T_case_begin("BroadcastBeforeMultitaskingDispatchDisabled", NULL);
- test_broadcast(ctx, multicast_action_dispatch_disabled);
+ test_broadcast(ctx, broadcast_action_dispatch_disabled);
T_case_end();
}
@@ -340,17 +364,17 @@ T_TEST_CASE(UnicastDuringMultitaskingDispatchDisabled)
T_TEST_CASE(BroadcastDuringMultitasking)
{
- test_broadcast(&test_instance, _SMP_Multicast_action);
+ test_broadcast(&test_instance, _SMP_Broadcast_action);
}
T_TEST_CASE(BroadcastDuringMultitaskingIRQDisabled)
{
- test_broadcast(&test_instance, multicast_action_irq_disabled);
+ test_broadcast(&test_instance, broadcast_action_irq_disabled);
}
T_TEST_CASE(BroadcastDuringMultitaskingDispatchDisabled)
{
- test_broadcast(&test_instance, multicast_action_dispatch_disabled);
+ test_broadcast(&test_instance, broadcast_action_dispatch_disabled);
}
static void Init(rtems_task_argument arg)