diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-07-27 13:40:51 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-07-28 19:32:24 +0200 |
commit | cbb1103a3ca9d2f42501ba373b5d559b981fb1c7 (patch) | |
tree | 8e20c863237d95390b49c82d7ee45791389b5a2a /testsuites/smptests | |
parent | score: Remove processor event broadcast/receive (diff) | |
download | rtems-cbb1103a3ca9d2f42501ba373b5d559b981fb1c7.tar.bz2 |
score: Simplify SMP processor state handling
The per-CPU states which control the SMP system initialization were added quite
early during the SMP support development. Replace this initial implementation
with a simplified one. There is no longer a global SMP lock required which
serialized the state changes of all processors. The new implementation better
integrates with the per-CPU jobs.
Diffstat (limited to '')
-rw-r--r-- | testsuites/smptests/smpfatal01/init.c | 57 | ||||
-rw-r--r-- | testsuites/smptests/smpfatal01/smpfatal01.doc | 3 | ||||
-rw-r--r-- | testsuites/smptests/smpfatal02/init.c | 21 | ||||
-rw-r--r-- | testsuites/smptests/smpfatal02/smpfatal02.doc | 3 |
4 files changed, 61 insertions, 23 deletions
diff --git a/testsuites/smptests/smpfatal01/init.c b/testsuites/smptests/smpfatal01/init.c index 0fd5f3fc46..6ee08cf653 100644 --- a/testsuites/smptests/smpfatal01/init.c +++ b/testsuites/smptests/smpfatal01/init.c @@ -32,6 +32,8 @@ const char rtems_test_name[] = "SMPFATAL 1"; static uint32_t main_cpu; +static uint32_t other_cpu; + static SMP_barrier_Control barrier = SMP_BARRIER_CONTROL_INITIALIZER; static void Init(rtems_task_argument arg) @@ -45,35 +47,59 @@ static void fatal_extension( rtems_fatal_code code ) { - SMP_barrier_State barrier_state = SMP_BARRIER_STATE_INITIALIZER; + assert(!always_set_to_false); if (source == RTEMS_FATAL_SOURCE_SMP) { + SMP_barrier_State barrier_state = SMP_BARRIER_STATE_INITIALIZER; + uint32_t cpu_count = rtems_scheduler_get_processor_maximum(); uint32_t self = rtems_scheduler_get_processor(); - assert(!always_set_to_false); - assert(code == SMP_FATAL_SHUTDOWN); + if (self == other_cpu) { + assert(code == SMP_FATAL_SHUTDOWN); + } else { + assert(code == SMP_FATAL_SHUTDOWN_RESPONSE); + } + + _SMP_barrier_Wait(&barrier, &barrier_state, cpu_count); if (self == main_cpu) { uint32_t cpu; - for (cpu = 0; cpu < MAX_CPUS; ++cpu) { + for (cpu = 0; cpu < cpu_count; ++cpu) { const Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu ); Per_CPU_State state = _Per_CPU_Get_state(per_cpu); assert(state == PER_CPU_STATE_SHUTDOWN); } + for (cpu = cpu_count; cpu < MAX_CPUS; ++cpu) { + const Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu ); + Per_CPU_State state = _Per_CPU_Get_state(per_cpu); + + assert(state == PER_CPU_STATE_INITIAL); + } + TEST_END(); + } else { + _SMP_barrier_Wait(&barrier, &barrier_state, cpu_count); } } +} - _SMP_barrier_Wait( - &barrier, - &barrier_state, - rtems_scheduler_get_processor_maximum() - ); +static void shutdown_handler(void *arg) +{ + _SMP_Request_shutdown(); + _SMP_Fatal(SMP_FATAL_SHUTDOWN); } +static const Per_CPU_Job_context shutdown_context = { + .handler = shutdown_handler +}; + +static Per_CPU_Job shutdown_job = { + .context = &shutdown_context +}; + static rtems_status_code test_driver_init( rtems_device_major_number major, rtems_device_minor_number minor, @@ -89,6 +115,7 @@ static rtems_status_code test_driver_init( assert(rtems_configuration_get_maximum_processors() == MAX_CPUS); main_cpu = self; + other_cpu = (self + 1) % cpu_count; for (cpu = 0; cpu < MAX_CPUS; ++cpu) { const Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu ); @@ -107,10 +134,14 @@ static rtems_status_code test_driver_init( } if (cpu_count > 1) { - uint32_t other = (self + 1) % cpu_count; - Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( other ); - - _Per_CPU_Set_state(per_cpu, PER_CPU_STATE_SHUTDOWN); + Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( other_cpu ); + + _Per_CPU_Add_job(per_cpu, &shutdown_job); + _Atomic_Fetch_or_ulong( + &per_cpu->message, + SMP_MESSAGE_PERFORM_JOBS, + ATOMIC_ORDER_RELEASE + ); } else { TEST_END(); exit(0); diff --git a/testsuites/smptests/smpfatal01/smpfatal01.doc b/testsuites/smptests/smpfatal01/smpfatal01.doc index c037cfe78b..c6b54b7dd1 100644 --- a/testsuites/smptests/smpfatal01/smpfatal01.doc +++ b/testsuites/smptests/smpfatal01/smpfatal01.doc @@ -4,7 +4,8 @@ test set name: smpfatal01 directives: - - _Per_CPU_State_change() + - _SMP_Request_shutdown() + - _SMP_Request_start_multitasking() concepts: diff --git a/testsuites/smptests/smpfatal02/init.c b/testsuites/smptests/smpfatal02/init.c index 25321ca27b..5528a4315d 100644 --- a/testsuites/smptests/smpfatal02/init.c +++ b/testsuites/smptests/smpfatal02/init.c @@ -47,6 +47,7 @@ static void fatal_extension( { SMP_barrier_State barrier_state = SMP_BARRIER_STATE_INITIALIZER; uint32_t self = rtems_scheduler_get_processor(); + uint32_t cpu_count = rtems_scheduler_get_processor_maximum(); assert(!always_set_to_false); @@ -57,25 +58,29 @@ static void fatal_extension( assert(code == 0xdeadbeef); _SMP_Request_shutdown(); + _SMP_barrier_Wait(&barrier, &barrier_state, cpu_count); - for (cpu = 0; cpu < MAX_CPUS; ++cpu) { + for (cpu = 0; cpu < cpu_count; ++cpu) { const Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu ); Per_CPU_State state = _Per_CPU_Get_state(per_cpu); assert(state == PER_CPU_STATE_SHUTDOWN); } + for (cpu = cpu_count; cpu < MAX_CPUS; ++cpu) { + const Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu ); + Per_CPU_State state = _Per_CPU_Get_state(per_cpu); + + assert(state == PER_CPU_STATE_INITIAL); + } + TEST_END(); } else if ( source == RTEMS_FATAL_SOURCE_SMP ) { assert(self != main_cpu); - assert(code == SMP_FATAL_SHUTDOWN); + assert(code == SMP_FATAL_SHUTDOWN_RESPONSE); + _SMP_barrier_Wait(&barrier, &barrier_state, cpu_count); + _SMP_barrier_Wait(&barrier, &barrier_state, cpu_count); } - - _SMP_barrier_Wait( - &barrier, - &barrier_state, - rtems_scheduler_get_processor_maximum() - ); } static rtems_status_code test_driver_init( diff --git a/testsuites/smptests/smpfatal02/smpfatal02.doc b/testsuites/smptests/smpfatal02/smpfatal02.doc index 9e2e002b37..b962f528ad 100644 --- a/testsuites/smptests/smpfatal02/smpfatal02.doc +++ b/testsuites/smptests/smpfatal02/smpfatal02.doc @@ -4,7 +4,8 @@ test set name: smpfatal02 directives: - - _Per_CPU_State_change() + - _Terminate() + - _SMP_Start_multitasking_on_secondary_processor() concepts: |