summaryrefslogtreecommitdiff
path: root/spm/cactus/cactus_tests
diff options
context:
space:
mode:
authorMadhukar Pappireddy <madhukar.pappireddy@arm.com>2021-10-26 14:50:52 -0500
committerMadhukar Pappireddy <madhukar.pappireddy@arm.com>2021-11-05 15:35:57 -0500
commita09d5f747ef59e9b12b9a54983c8d58d71651970 (patch)
treec73ce2f9ba205888aefa0a3a3dfe514e6cc22ee0 /spm/cactus/cactus_tests
parentdd7db24aaf872571b630b46add1995b3bec1b6fd (diff)
feat: add helper functions for SP sleep
This patch introduces new helper utilities: virtualcounter_read() and sp_sleep_elapsed_time() which are further used in sp_sleep() utility. This patch also adds a needed isb when reading the virtual counter, to prevent reading stale values, as well as reducing the number of reads of the virtual counter required. Refer Arm ARM D11.2.2 Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com> Change-Id: Icaf1777e85ee2efc043bfa83d630edf54bf5a099
Diffstat (limited to 'spm/cactus/cactus_tests')
-rw-r--r--spm/cactus/cactus_tests/cactus_test_interrupts.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/spm/cactus/cactus_tests/cactus_test_interrupts.c b/spm/cactus/cactus_tests/cactus_test_interrupts.c
index b675dfc..aa39ef2 100644
--- a/spm/cactus/cactus_tests/cactus_test_interrupts.c
+++ b/spm/cactus/cactus_tests/cactus_test_interrupts.c
@@ -13,18 +13,16 @@
CACTUS_CMD_HANDLER(sleep_cmd, CACTUS_SLEEP_CMD)
{
- uint64_t timer_freq = read_cntfrq_el0();
- uint64_t time1, time2, time_lapsed;
+ uint64_t time_lapsed;
uint32_t sleep_time = cactus_get_sleep_time(*args);
- VERBOSE("Request to sleep %x for %ums.\n", ffa_dir_msg_dest(*args), sleep_time);
+ VERBOSE("Request to sleep %x for %ums.\n", ffa_dir_msg_dest(*args),
+ sleep_time);
- time1 = read_cntvct_el0();
- sp_sleep(sleep_time);
- time2 = read_cntvct_el0();
+ time_lapsed = sp_sleep_elapsed_time(sleep_time);
- /* Lapsed time should be at least equal to sleep time */
- time_lapsed = ((time2 - time1) * 1000) / timer_freq;
+ /* Lapsed time should be at least equal to sleep time. */
+ VERBOSE("Sleep complete: %llu\n", time_lapsed);
return cactus_response(ffa_dir_msg_dest(*args),
ffa_dir_msg_source(*args),