diff options
author | Douglas Raillard <douglas.raillard@arm.com> | 2016-11-15 14:37:46 +0000 |
---|---|---|
committer | Sandrine Bailleux <sandrine.bailleux@arm.com> | 2016-12-06 11:49:33 +0000 |
commit | 6f234d2d5c65b6f82b93fd39d68427c51a09bc86 (patch) | |
tree | bf7826797f0fe0d738828d29fd8105f91fb268e7 /tests/runtime_services | |
parent | d9b3d26331950a00120bb44a21ee71d157e4d783 (diff) |
Use tftf_program_timer_and_sys_suspend in tests
Replace race prone timer programming followed by system suspend with the
safe function.
Change-Id: Ie0fa3c339fd706b1233e3df508ffda5c482fb914
Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
Diffstat (limited to 'tests/runtime_services')
2 files changed, 65 insertions, 45 deletions
diff --git a/tests/runtime_services/standard_service/psci/api_tests/psci_stat/test_psci_stat.c b/tests/runtime_services/standard_service/psci/api_tests/psci_stat/test_psci_stat.c index 92d7c10..70b34ee 100644 --- a/tests/runtime_services/standard_service/psci/api_tests/psci_stat/test_psci_stat.c +++ b/tests/runtime_services/standard_service/psci/api_tests/psci_stat/test_psci_stat.c @@ -810,7 +810,8 @@ test_result_t test_psci_stats_cpu_off(void) test_result_t test_psci_stats_system_suspend(void) { u_register_t lead_mpid, target_mpid; - int cpu_node, ret; + int cpu_node; + int ret; ret = tftf_get_psci_feature_info(SMC_PSCI_SYSTEM_SUSPEND64); if (ret == PSCI_E_NOT_SUPPORTED) { @@ -862,18 +863,12 @@ test_result_t test_psci_stats_system_suspend(void) /* Update the stats corresponding to the lead CPU as well */ populate_all_stats_all_lvls(); - /* Program timer to fire after delay */ - ret = tftf_program_timer(PLAT_SUSPEND_ENTRY_TIME); - if (ret) { - ERROR("Timer programming failed with error %d\n", ret); - return TEST_RESULT_FAIL; - } - ret = tftf_system_suspend(); + /* Program timer to fire after delay and issue system suspend */ + ret = tftf_program_timer_and_sys_suspend(PLAT_SUSPEND_ENTRY_TIME, + NULL, NULL); tftf_cancel_timer(); - if (ret) { - ERROR("System suspend API failed with error %d\n", ret); + if (ret) return TEST_RESULT_FAIL; - } /* That target level for SYSTEM SUSPEND is PLAT_MAX_PWR_LEVEL */ verify_stats_target_lvl = PLAT_MAX_PWR_LEVEL; diff --git a/tests/runtime_services/standard_service/psci/api_tests/system_suspend/test_psci_system_suspend.c b/tests/runtime_services/standard_service/psci/api_tests/system_suspend/test_psci_system_suspend.c index 4f8b29b..ec09e5f 100644 --- a/tests/runtime_services/standard_service/psci/api_tests/system_suspend/test_psci_system_suspend.c +++ b/tests/runtime_services/standard_service/psci/api_tests/system_suspend/test_psci_system_suspend.c @@ -124,6 +124,7 @@ static test_result_t sys_suspend_from_all_cores(void) { unsigned long long my_mpid = read_mpidr_el1() & MPID_MASK, target_mpid; unsigned int core_pos = platform_get_core_pos(my_mpid); + int ret; int psci_ret; /* Increment the count of CPUs in the test */ @@ -139,17 +140,16 @@ static test_result_t sys_suspend_from_all_cores(void) tftf_timer_register_handler(suspend_wakeup_handler); /* Program timer to fire after delay */ - tftf_program_timer(PLAT_SUSPEND_ENTRY_TIME); - psci_ret = tftf_system_suspend(); + ret = tftf_program_timer_and_sys_suspend(PLAT_SUSPEND_ENTRY_TIME, + NULL, NULL); /* Wait until the IRQ wake interrupt is received */ while (!ACCESS(wakeup_irq_rcvd[core_pos])) ; - if (psci_ret != PSCI_E_SUCCESS) { - tftf_testcase_printf( - "Failed to suspend system from core" - "%x ret: %x \n", core_pos, psci_ret); + if (ret) { + tftf_testcase_printf("Failed to program timer or suspend " + "system from core %x\n", core_pos); return TEST_RESULT_FAIL; } @@ -407,7 +407,8 @@ test_result_t test_psci_sys_susp_multiple_iteration(void) unsigned int lead_mpid = read_mpidr_el1() & MPID_MASK; unsigned int core_pos = platform_get_core_pos(lead_mpid); const unsigned int sgi_id = IRQ_NS_SGI_0; - test_result_t psci_ret; + int psci_ret; + int timer_ret; if ((is_psci_sys_susp_supported()) == PSCI_E_NOT_SUPPORTED) { tftf_testcase_printf("System suspend is not supported " @@ -428,19 +429,22 @@ test_result_t test_psci_sys_susp_multiple_iteration(void) /* * Program the wakeup timer, this will serve as the wake-up event - * to come out of suspend state + * to come out of suspend state, and issue system suspend */ - tftf_program_timer(PLAT_SUSPEND_ENTRY_TIME); - - /* Issue system suspend */ - psci_ret = tftf_system_suspend(); + tftf_program_timer_and_sys_suspend( + PLAT_SUSPEND_ENTRY_TIME, &timer_ret, &psci_ret); while (!ACCESS(wakeup_irq_rcvd[core_pos])) ; if (psci_ret != PSCI_E_SUCCESS) { - tftf_testcase_printf("Failed with return value %x\n", - psci_ret); + tftf_testcase_printf("System suspend failed with return value %i\n", + psci_ret); + return TEST_RESULT_FAIL; + } + if (timer_ret) { + tftf_testcase_printf("Timer programming failed with return value %i\n", + timer_ret); return TEST_RESULT_FAIL; } } @@ -605,7 +609,9 @@ test_result_t test_psci_sys_susp_validate_ram(void) unsigned int core_pos = platform_get_core_pos(read_mpidr_el1()); unsigned long prev_hash_val = 0; unsigned long present_hash_val = 0; - unsigned int psci_ret; + int psci_ret; + int timer_ret; + test_result_t ret = TEST_RESULT_SUCCESS; if ((is_psci_sys_susp_supported()) == PSCI_E_NOT_SUPPORTED) { @@ -622,11 +628,13 @@ test_result_t test_psci_sys_susp_validate_ram(void) tftf_timer_register_handler(suspend_wakeup_handler); - /* Program timer to fire interrupt after timer expires */ - tftf_program_timer(SUSPEND_TIME_10_SECS); + /* + * Program timer to fire interrupt after timer expires and issue + * system suspend + */ + tftf_program_timer_and_sys_suspend(SUSPEND_TIME_10_SECS, + &timer_ret, &psci_ret); - /* Issue system suspend */ - psci_ret = tftf_system_suspend(); while (!ACCESS(wakeup_irq_rcvd[core_pos])) ; if (psci_ret == PSCI_E_SUCCESS) { @@ -646,6 +654,11 @@ test_result_t test_psci_sys_susp_validate_ram(void) ret = TEST_RESULT_FAIL; } + if (timer_ret) { + tftf_testcase_printf("Failed: timer programming \n"); + ret = TEST_RESULT_FAIL; + } + /* Unregister timer handler */ tftf_timer_unregister_handler(); tftf_cancel_timer(); @@ -728,7 +741,8 @@ test_result_t test_psci_sys_susp_with_cores_in_suspend(void) unsigned int core_pos = platform_get_core_pos(read_mpidr_el1()); unsigned int target_mpid, target_node; unsigned int lead_mpid = read_mpidr_el1() & MPID_MASK; - test_result_t psci_ret; + int psci_ret; + int timer_ret; test_result_t ret = TEST_RESULT_SUCCESS; if ((is_psci_sys_susp_supported()) == PSCI_E_NOT_SUPPORTED) { @@ -776,12 +790,13 @@ test_result_t test_psci_sys_susp_with_cores_in_suspend(void) /* Wait for 10 ms to ensure all the secondaries have suspended */ waitms(10); - /* Register and program timer */ + /* + * Register and program timer, then issue a system suspend + * when other cores are in suspend state + */ tftf_timer_register_handler(suspend_wakeup_handler); - tftf_program_timer(PLAT_SUSPEND_ENTRY_TIME); - - /* Issue system suspend when other cores are in suspend state */ - psci_ret = tftf_system_suspend(); + tftf_program_timer_and_sys_suspend( + PLAT_SUSPEND_ENTRY_TIME, &timer_ret, &psci_ret); /* Wake all non-lead CPUs */ for_each_cpu(target_node) { @@ -799,6 +814,10 @@ test_result_t test_psci_sys_susp_with_cores_in_suspend(void) tftf_testcase_printf("Entered suspend with cores in suspend\n"); ret = TEST_RESULT_FAIL; } + if (timer_ret) { + tftf_testcase_printf("Failed to program the timer\n"); + ret = TEST_RESULT_FAIL; + } /* Unregister and cancel timer */ tftf_timer_unregister_handler(); tftf_cancel_timer(); @@ -834,7 +853,8 @@ test_result_t test_psci_sys_susp_with_cores_on(void) unsigned int lead_cluster = MPIDR_CLUSTER_ID(read_mpidr_el1()); unsigned int core_pos; unsigned int target_mpid, target_node; - test_result_t psci_ret; + int psci_ret; + int timer_ret; test_result_t ret = TEST_RESULT_SUCCESS; if ((is_psci_sys_susp_supported()) == PSCI_E_NOT_SUPPORTED) { @@ -876,11 +896,12 @@ test_result_t test_psci_sys_susp_with_cores_on(void) /* Register timer handler */ tftf_timer_register_handler(suspend_wakeup_handler); - /* Program timer to fire after delay */ - tftf_program_timer(PLAT_SUSPEND_ENTRY_TIME); - - /* Issue system suspend with other cores in ON state */ - psci_ret = tftf_system_suspend(); + /* + * Program timer to fire after delay and issue system suspend with + * other cores in ON state + */ + tftf_program_timer_and_sys_suspend(PLAT_SUSPEND_ENTRY_TIME, + &timer_ret, &psci_ret); /* Send event to CPUs waiting for `waitq` event. */ for_each_cpu(target_node) { @@ -896,11 +917,15 @@ test_result_t test_psci_sys_susp_with_cores_on(void) /* Check return value from system suspend API */ if (psci_ret != PSCI_E_DENIED) { - tftf_testcase_printf("Test failed with return value: %x \n", - psci_ret); + tftf_testcase_printf("Test failed when suspending with return " + "value: %x \n", psci_ret); + ret = TEST_RESULT_FAIL; + } + if (timer_ret) { + tftf_testcase_printf("Test failed with return value when " + "programming the timer: %x \n", timer_ret); ret = TEST_RESULT_FAIL; } - tftf_timer_unregister_handler(); tftf_cancel_timer(); return ret; |