summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2024-04-08 11:44:39 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2024-04-16 07:26:35 +0200
commitd45fab844932299118569c5dc00393e61ac94bf9 (patch)
tree7c41a485d1f657b8244968ef838112bb6e797102
parentsmpmulticast01: Ignore SMP_FATAL_SHUTDOWN_RESPONSE (diff)
downloadrtems-d45fab844932299118569c5dc00393e61ac94bf9.tar.bz2
smptests/smpipi01: Fix sporadic test failure
Make sure that the last IPI is processed before the next test case is carried out.
-rw-r--r--testsuites/smptests/smpipi01/init.c48
1 files changed, 42 insertions, 6 deletions
diff --git a/testsuites/smptests/smpipi01/init.c b/testsuites/smptests/smpipi01/init.c
index 290d13775f..f8172fed96 100644
--- a/testsuites/smptests/smpipi01/init.c
+++ b/testsuites/smptests/smpipi01/init.c
@@ -198,6 +198,43 @@ static const Per_CPU_Job_context counter_1_job_context = {
.arg = &test_instance
};
+static void sync_handler(void *arg)
+{
+ test_context *ctx = arg;
+ SMP_barrier_State *bs = &ctx->worker_barrier_state;
+
+ /* (E) */
+ barrier(ctx, bs);
+}
+
+static const Per_CPU_Job_context sync_context = {
+ .handler = sync_handler,
+ .arg = &test_instance
+};
+
+static void wait_for_ipi_done(test_context *ctx, Per_CPU_Control *cpu)
+{
+ Per_CPU_Job job;
+ unsigned long done;
+
+ job.context = &sync_context;
+ _Per_CPU_Submit_job(cpu, &job);
+
+ while (cpu->isr_nest_level == 0) {
+ RTEMS_COMPILER_MEMORY_BARRIER();
+ }
+
+ /* (E) */
+ barrier(ctx, &ctx->main_barrier_state);
+
+ while (cpu->isr_nest_level != 0) {
+ RTEMS_COMPILER_MEMORY_BARRIER();
+ }
+
+ done = _Atomic_Load_ulong( &job.done, ATOMIC_ORDER_ACQUIRE );
+ rtems_test_assert( done == PER_CPU_JOB_DONE );
+}
+
static void test_send_message_flood(
test_context *ctx,
uint32_t cpu_count
@@ -211,20 +248,15 @@ static void test_send_message_flood(
ctx->jobs[cpu_index][0].context = &counter_0_job_context;
ctx->jobs[cpu_index][1].context = &counter_1_job_context;
- _Per_CPU_Submit_job(cpu, &ctx->jobs[cpu_index][0]);
+ _Per_CPU_Add_job(cpu, &ctx->jobs[cpu_index][0]);
}
for (cpu_index = 0; cpu_index < cpu_count; ++cpu_index) {
Per_CPU_Control *cpu;
- Per_CPU_Control *cpu_self;
uint32_t i;
cpu = _Per_CPU_Get_by_index(cpu_index);
- cpu_self = _Thread_Dispatch_disable();
- _SMP_Synchronize();
- _Thread_Dispatch_enable(cpu_self);
-
for (i = 0; i < cpu_count; ++i) {
if (i != cpu_index) {
ctx->copy_counters[i] = ctx->counters[i].value;
@@ -235,6 +267,10 @@ static void test_send_message_flood(
_SMP_Send_message(cpu, SMP_MESSAGE_PERFORM_JOBS);
}
+ if (cpu_index != cpu_index_self) {
+ wait_for_ipi_done(ctx, cpu);
+ }
+
for (i = 0; i < cpu_count; ++i) {
if (i != cpu_index) {
rtems_test_assert(ctx->copy_counters[i] == ctx->counters[i].value);