aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeepika Bhavnani <deepika.bhavnani@arm.com>2019-09-06 21:48:56 +0300
committerDeepika Bhavnani <deepika.bhavnani@arm.com>2019-10-18 11:52:48 -0500
commit8108c9a3a7e627a7464affb5fdb169202c3012b1 (patch)
tree5ef1ae7c9c8e2253744ed436cf5814206550523c
parent0012dbc2a841abeff25be8be1113f19073ee4d2c (diff)
downloadtf-a-tests-8108c9a3a7e627a7464affb5fdb169202c3012b1.tar.gz
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 <deepika.bhavnani@arm.com> Change-Id: Ice62d0e7ef0db63ccb030e8dc1a83d9bd55e70f2
-rw-r--r--tftf/tests/runtime_services/standard_service/psci/api_tests/system_off/test_system_off.c79
-rw-r--r--tftf/tests/tests-manual.xml5
2 files changed, 74 insertions, 10 deletions
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 2ac6550fd..a6d691412 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 <psci.h>
#include <smccc.h>
#include <tftf_lib.h>
+#include <test_helpers.h>
+#include <power_management.h>
+
+/* 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 15a9609fc..0fd6e552b 100644
--- a/tftf/tests/tests-manual.xml
+++ b/tftf/tests/tests-manual.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (c) 2018, Arm Limited. All rights reserved.
+ Copyright (c) 2018-2019, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
-->
@@ -15,7 +15,8 @@
</testsuite>
<testsuite name="System off test" description="Validate SYSTEM_OFF PSCI call">
- <testcase name="System Off" function="test_system_off" />
+ <testcase name="System Off" function="test_system_off" />
+ <testcase name="System Off Secondary CPU" function="test_system_off_cpu_other_than_lead" />
</testsuite>
<testsuite name="PSCI mem_protect" description="Check the mem_protect feature">