diff mbox

[PMQA] cpufreq: consider sampling rate to calculate scaling time

Message ID 1407226146-10533-1-git-send-email-sanjay.rawat@linaro.org
State New
Headers show

Commit Message

Sanjay Singh Rawat Aug. 5, 2014, 8:09 a.m. UTC
- add the governor sampling rate with the frequency transition latency to
make sure tansition happens.
- bug 77

Signed-off-by: Sanjay Singh Rawat <sanjay.rawat@linaro.org>
---
 include/functions.sh | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/include/functions.sh b/include/functions.sh
index 417c725..5823a81 100644
--- a/include/functions.sh
+++ b/include/functions.sh
@@ -123,6 +123,17 @@  wait_latency() {
     local dirpath=$CPU_PATH/$cpu/cpufreq
     local latency=
     local nrfreq=
+    local sampling_rate=
+    local sleep_time=
+    local gov=$(cat $dirpath/scaling_governor)
+
+    # consider per-policy governor case
+    if [ -e $CPU_PATH/$cpu/cpufreq/$gov ]; then
+	sampling_rate=$(cat $CPU_PATH/$cpu/cpufreq/$gov/sampling_rate)
+    else
+        sampling_rate=$(cat $CPU_PATH/cpufreq/$gov/sampling_rate)
+    fi
+    sampling_rate=$((sampling_rate * 1000)) # unit nsec
 
     latency=$(cat $dirpath/cpuinfo_transition_latency)
     if [ $? -ne 0 ]; then
@@ -135,7 +146,10 @@  wait_latency() {
     fi
 
     nrfreq=$((nrfreq + 1))
-    ../utils/nanosleep $(($nrfreq * $latency))
+
+    sleep_time=$(($latency + $sampling_rate))
+
+    ../utils/nanosleep $(($nrfreq * $sleep_time))
 }
 
 frequnit() {