From fc1d1e2df02e61279c16d280f4f48c83f8fa7927 Mon Sep 17 00:00:00 2001 From: dp-arm Date: Fri, 14 Oct 2016 11:18:09 +0100 Subject: [PATCH 1/2] user guide: Document `ENABLE_RUNTIME_INSTRUMENTATION` option Change-Id: I8e50df67e860b9589834445761a7b9927690fdce Signed-off-by: dp-arm --- docs/user-guide.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/user-guide.md b/docs/user-guide.md index 5b73b66354..140977e7c8 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -466,6 +466,12 @@ performed. Note: `TRUSTED_BOARD_BOOT` is currently not supported when `LOAD_IMAGE_V2` is enabled. +* `ENABLE_RUNTIME_INSTRUMENTATION`: Boolean option to enable runtime + instrumentation which injects timestamp collection points into + Trusted Firmware to allow runtime performance to be measured. + Currently, only PSCI is instrumented. Enabling this option enables + the `ENABLE_PMF` build option as well. Default is 0. + #### ARM development platform specific build options * `ARM_TSP_RAM_LOCATION`: location of the TSP binary. Options: From bfef610667b75e731d0d263b069369f7695c6c83 Mon Sep 17 00:00:00 2001 From: dp-arm Date: Mon, 31 Oct 2016 17:17:21 +0000 Subject: [PATCH 2/2] Perform a cache flush after ENTER PSCI timestamp capture Without an explicit cache flush, the next timestamp captured might have a bogus value. This can happen if the following operations happen in order, on a CPU that's being powered down. 1) ENTER PSCI timestamp is captured with caches enabled. 2) The next timestamp (ENTER_HW_LOW_PWR) is captured with caches disabled. 3) On a system that uses a write-back cache configuration, the cache line that holds the PMF timestamps is evicted. After step 1), the ENTER_PSCI timestamp is cached and not in main memory. After step 2), the ENTER_HW_LOW_PWR timestamp is stored in main memory. Before the CPU power down happens, the hardware evicts the cache line that contains the PMF timestamps for this service. As a result, the timestamp captured in step 2) is overwritten with a bogus value. Change-Id: Ic1bd816498d1a6d4dc16540208ed3a5efe43f529 Signed-off-by: dp-arm --- services/std_svc/std_svc_setup.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/std_svc/std_svc_setup.c b/services/std_svc/std_svc_setup.c index 97a9fbd6a5..010bb8f794 100644 --- a/services/std_svc/std_svc_setup.c +++ b/services/std_svc/std_svc_setup.c @@ -81,9 +81,14 @@ uintptr_t std_svc_smc_handler(uint32_t smc_fid, uint64_t ret; #if ENABLE_RUNTIME_INSTRUMENTATION + + /* + * Flush cache line so that even if CPU power down happens + * the timestamp update is reflected in memory. + */ PMF_WRITE_TIMESTAMP(rt_instr_svc, RT_INSTR_ENTER_PSCI, - PMF_NO_CACHE_MAINT, + PMF_CACHE_MAINT, get_cpu_data(cpu_data_pmf_ts[CPU_DATA_PMF_TS0_IDX])); #endif