summaryrefslogtreecommitdiff
path: root/lib/psci/psci_suspend.c
diff options
context:
space:
mode:
authordp-arm <dimitris.papastamos@arm.com>2016-09-19 11:18:44 +0100
committerdp-arm <dimitris.papastamos@arm.com>2016-10-12 15:36:49 +0100
commit872be88a2916f45d3de38120ede8c8b199b7498f (patch)
treec3cb92eeef9b70c1d8b7a34a95a2396d1dbc4d27 /lib/psci/psci_suspend.c
parentf10796a0686ee361fde54b887da05dd25e0ed2cf (diff)
Add PMF instrumentation points in TF
In order to quantify the overall time spent in the PSCI software implementation, an initial collection of PMF instrumentation points has been added. Instrumentation has been added to the following code paths: - Entry to PSCI SMC handler. The timestamp is captured as early as possible during the runtime exception and stored in memory before entering the PSCI SMC handler. - Exit from PSCI SMC handler. The timestamp is captured after normal return from the PSCI SMC handler or if a low power state was requested it is captured in the bl31 warm boot path before return to normal world. - Entry to low power state. The timestamp is captured before entry to a low power state which implies either standby or power down. As these power states are mutually exclusive, only one timestamp is defined to describe both. It is possible to differentiate between the two power states using the PSCI STAT interface. - Exit from low power state. The timestamp is captured after a standby or power up operation has completed. To calculate the number of cycles spent running code in Trusted Firmware one can perform the following calculation: (exit_psci - enter_psci) - (exit_low_pwr - enter_low_pwr). The resulting number of cycles can be converted to time given the frequency of the counter. Change-Id: Ie3b8f3d16409b6703747093b3a2d5c7429ad0166 Signed-off-by: dp-arm <dimitris.papastamos@arm.com>
Diffstat (limited to 'lib/psci/psci_suspend.c')
-rw-r--r--lib/psci/psci_suspend.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/psci/psci_suspend.c b/lib/psci/psci_suspend.c
index 0887e3b2..10d2481d 100644
--- a/lib/psci/psci_suspend.c
+++ b/lib/psci/psci_suspend.c
@@ -37,6 +37,8 @@
#include <cpu_data.h>
#include <debug.h>
#include <platform.h>
+#include <pmf.h>
+#include <runtime_instr.h>
#include <stddef.h>
#include "psci_private.h"
@@ -212,6 +214,19 @@ exit:
return;
if (is_power_down_state) {
+#if ENABLE_RUNTIME_INSTRUMENTATION
+
+ /*
+ * Update the timestamp with cache off. We assume this
+ * timestamp can only be read from the current CPU and the
+ * timestamp cache line will be flushed before return to
+ * normal world on wakeup.
+ */
+ PMF_CAPTURE_TIMESTAMP(rt_instr_svc,
+ RT_INSTR_ENTER_HW_LOW_PWR,
+ PMF_NO_CACHE_MAINT);
+#endif
+
/* The function calls below must not return */
if (psci_plat_pm_ops->pwr_domain_pwr_down_wfi)
psci_plat_pm_ops->pwr_domain_pwr_down_wfi(state_info);
@@ -219,6 +234,12 @@ exit:
psci_power_down_wfi();
}
+#if ENABLE_RUNTIME_INSTRUMENTATION
+ PMF_CAPTURE_TIMESTAMP(rt_instr_svc,
+ RT_INSTR_ENTER_HW_LOW_PWR,
+ PMF_NO_CACHE_MAINT);
+#endif
+
/*
* We will reach here if only retention/standby states have been
* requested at multiple power levels. This means that the cpu
@@ -226,6 +247,12 @@ exit:
*/
wfi();
+#if ENABLE_RUNTIME_INSTRUMENTATION
+ PMF_CAPTURE_TIMESTAMP(rt_instr_svc,
+ RT_INSTR_EXIT_HW_LOW_PWR,
+ PMF_NO_CACHE_MAINT);
+#endif
+
/*
* After we wake up from context retaining suspend, call the
* context retaining suspend finisher.