From 8108c9a3a7e627a7464affb5fdb169202c3012b1 Mon Sep 17 00:00:00 2001 From: Deepika Bhavnani Date: Fri, 6 Sep 2019 21:48:56 +0300 Subject: Extend SYSTEM_OFF test case Extend SYSTEM_OFF to involve more than just the lead CPU. The typical way to use SYSTEM_OFF is to use calls to CPU_OFF on all online cores except for the last one, which instead uses SYSTEM_OFF. test_system_off_cpu_other_than_lead() case is added to turn on any random CPU other then lead CPU and perform SYSTEM_OFF from the CPU which was turned ON. Signed-off-by: Deepika Bhavnani Change-Id: Ice62d0e7ef0db63ccb030e8dc1a83d9bd55e70f2 --- .../psci/api_tests/system_off/test_system_off.c | 79 +++++++++++++++++++--- tftf/tests/tests-manual.xml | 5 +- 2 files changed, 74 insertions(+), 10 deletions(-) (limited to 'tftf') diff --git a/tftf/tests/runtime_services/standard_service/psci/api_tests/system_off/test_system_off.c b/tftf/tests/runtime_services/standard_service/psci/api_tests/system_off/test_system_off.c index 2ac6550..a6d6914 100644 --- a/tftf/tests/runtime_services/standard_service/psci/api_tests/system_off/test_system_off.c +++ b/tftf/tests/runtime_services/standard_service/psci/api_tests/system_off/test_system_off.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Arm Limited. All rights reserved. + * Copyright (c) 2018-2019, Arm Limited. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -7,6 +7,37 @@ #include #include #include +#include +#include + +/* Generic function to call System OFF SMC */ +static test_result_t test_cpu_system_off(void) +{ + u_register_t curr_mpid = read_mpidr_el1() & MPID_MASK; + u_register_t mpid; + unsigned int cpu_node; + smc_args args = { SMC_PSCI_SYSTEM_OFF }; + + /* Wait for all other CPU's to turn off */ + for_each_cpu(cpu_node) { + mpid = tftf_get_mpidr_from_node(cpu_node); + /* Skip current CPU */ + if (mpid == curr_mpid) + continue; + + while (tftf_psci_affinity_info(mpid, + MPIDR_AFFLVL0) != PSCI_STATE_OFF) { + } + } + + INFO("System off from CPU MPID 0x%lx\n", curr_mpid); + tftf_notify_reboot(); + tftf_smc(&args); + + /* The PSCI SYSTEM_OFF call is not supposed to return */ + tftf_testcase_printf("System didn't shutdown properly\n"); + return TEST_RESULT_FAIL; +} /* * @Test_Aim@ Validate the SYSTEM_OFF call. @@ -15,17 +46,49 @@ */ test_result_t test_system_off(void) { - smc_args args = { SMC_PSCI_SYSTEM_OFF }; + if (tftf_is_rebooted() == 1) { + /* Successfully resumed from SYSTEM_OFF */ + return TEST_RESULT_SUCCESS; + } - if (tftf_is_rebooted()) { - /* Successfully resumed from system off */ + return test_cpu_system_off(); +} + +/* + * @Test_Aim@ Validate the SYSTEM_OFF call on CPU other than lead CPU + * Test SUCCESS in case of system shutdown. + * Test FAIL in case of execution not terminated. + */ +test_result_t test_system_off_cpu_other_than_lead(void) +{ + u_register_t lead_mpid = read_mpidr_el1() & MPID_MASK; + u_register_t cpu_mpid; + int psci_ret; + + SKIP_TEST_IF_LESS_THAN_N_CPUS(2); + + if (tftf_is_rebooted() == 1) { + /* Successfully resumed from SYSTEM_OFF */ return TEST_RESULT_SUCCESS; } - tftf_notify_reboot(); - tftf_smc(&args); + /* Power ON another CPU, other than the lead CPU */ + cpu_mpid = tftf_find_random_cpu_other_than(lead_mpid); + VERBOSE("CPU to be turned on MPID: 0x%lx\n", cpu_mpid); + psci_ret = tftf_cpu_on(cpu_mpid, + (uintptr_t)test_cpu_system_off, + 0); - /* The PSCI SYSTEM_OFF call is not supposed to return */ - tftf_testcase_printf("System didn't shutdown properly\n"); + if (psci_ret != PSCI_E_SUCCESS) { + tftf_testcase_printf("Failed to power on CPU 0x%lx (%d)\n", + cpu_mpid, psci_ret); + return TEST_RESULT_FAIL; + } + + /* Power down the lead CPU */ + INFO("Lead CPU to be turned off MPID: 0x%lx\n", lead_mpid); + tftf_cpu_off(); + + /* Test should not reach here */ return TEST_RESULT_FAIL; } diff --git a/tftf/tests/tests-manual.xml b/tftf/tests/tests-manual.xml index 15a9609..0fd6e55 100644 --- a/tftf/tests/tests-manual.xml +++ b/tftf/tests/tests-manual.xml @@ -1,7 +1,7 @@ @@ -15,7 +15,8 @@ - + + -- cgit v1.2.3