From: "hongbo.zhang" hongbo.zhang@linaro.com
If we want to set one cpufreq governor mode, we must check this mode is supported or not before setting it. Otherwise we will get failure reported, this differs from the case that one mode is said to be supported but doesn't work well at all.
hongbo.zhang (1): cpufreq: governor mode should be checked if it is supported before setting it.
cpufreq/cpufreq_04.sh | 7 ++++++- cpufreq/cpufreq_05.sh | 54 +++++++++++++++++++++++++++++++++---------------- cpufreq/cpufreq_06.sh | 6 ++++++ cpufreq/cpufreq_07.sh | 6 ++++++ cpufreq/cpufreq_08.sh | 6 ++++++ cpufreq/cpufreq_09.sh | 6 ++++++ 6 files changed, 67 insertions(+), 18 deletions(-)
From: "hongbo.zhang" hongbo.zhang@linaro.com
Signed-off-by: hongbo.zhang hongbo.zhang@linaro.com --- cpufreq/cpufreq_04.sh | 7 ++++++- cpufreq/cpufreq_05.sh | 54 +++++++++++++++++++++++++++++++++---------------- cpufreq/cpufreq_06.sh | 6 ++++++ cpufreq/cpufreq_07.sh | 6 ++++++ cpufreq/cpufreq_08.sh | 6 ++++++ cpufreq/cpufreq_09.sh | 6 ++++++ 6 files changed, 67 insertions(+), 18 deletions(-)
diff --git a/cpufreq/cpufreq_04.sh b/cpufreq/cpufreq_04.sh index a4ee5db..5b1c508 100755 --- a/cpufreq/cpufreq_04.sh +++ b/cpufreq/cpufreq_04.sh @@ -51,4 +51,9 @@ if [ $(id -u) != 0 ]; then exit 0 fi
-for_each_cpu for_each_frequency check_frequency || exit 1 +supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "userspace") +if [ -z $supported ]; then + log_skip "userspace not supported" +else + for_each_cpu for_each_frequency check_frequency || exit 1 +fi diff --git a/cpufreq/cpufreq_05.sh b/cpufreq/cpufreq_05.sh index 560ae3d..ae6b670 100755 --- a/cpufreq/cpufreq_05.sh +++ b/cpufreq/cpufreq_05.sh @@ -51,30 +51,50 @@ switch_userspace() { set_governor $cpu 'userspace' }
-for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do - switch_ondemand $cpu -done -check "'ondemand' directory exists" "test -d $CPU_PATH/cpufreq/ondemand" +supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "ondemand") +if [ -z $supported ]; then + log_skip "ondemand not supported" +else + for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do + switch_ondemand $cpu + done + check "'ondemand' directory exists" "test -d $CPU_PATH/cpufreq/ondemand" +fi
-for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do - switch_conservative $cpu -done -check "'conservative' directory exists" "test -d $CPU_PATH/cpufreq/conservative" +supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "conservative") +if [ -z $supported ]; then + log_skip "conservative not supported" +else + for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do + switch_conservative $cpu + done + check "'conservative' directory exists" "test -d $CPU_PATH/cpufreq/conservative" +fi
-for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do - switch_userspace $cpu -done +supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "userspace") +if [ -z $supported ]; then + log_skip "userspace not supported" +else + for cpu in $(ls $CPU_PATH | grep "cpu[0-9].*"); do + switch_userspace $cpu + done
-check "'ondemand' directory is not there" "test ! -d $CPU_PATH/cpufreq/ondemand" -check "'conservative' directory is not there" "test ! -d $CPU_PATH/cpufreq/conservative" + check "'ondemand' directory is not there" "test ! -d $CPU_PATH/cpufreq/ondemand" + check "'conservative' directory is not there" "test ! -d $CPU_PATH/cpufreq/conservative" +fi
# if more than one cpu, combine governors nrcpus=$(ls $CPU_PATH | grep "cpu[0-9].*" | wc -l) if [ $nrcpus > 1 ]; then - switch_ondemand cpu0 - switch_conservative cpu1 - check "'ondemand' directory exists" "test -d $CPU_PATH/cpufreq/ondemand" - check "'conservative' directory exists" "test -d $CPU_PATH/cpufreq/conservative" + affected=$(cat $CPU_PATH/cpu0/cpufreq/affected_cpus | grep 1) + if [ -z $affected ]; then + switch_ondemand cpu0 + switch_conservative cpu1 + check "'ondemand' directory exists" "test -d $CPU_PATH/cpufreq/ondemand" + check "'conservative' directory exists" "test -d $CPU_PATH/cpufreq/conservative" + else + log_skip "combine governors not supported" + fi fi
restore_governors diff --git a/cpufreq/cpufreq_06.sh b/cpufreq/cpufreq_06.sh index d67ce6d..215bf61 100755 --- a/cpufreq/cpufreq_06.sh +++ b/cpufreq/cpufreq_06.sh @@ -106,6 +106,12 @@ if [ $(id -u) != 0 ]; then exit 0 fi
+supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "userspace") +if [ -z $supported ]; then + log_skip "userspace not supported" + exit 0 +fi + save_governors save_frequencies
diff --git a/cpufreq/cpufreq_07.sh b/cpufreq/cpufreq_07.sh index 1505cb3..539e2d1 100755 --- a/cpufreq/cpufreq_07.sh +++ b/cpufreq/cpufreq_07.sh @@ -82,6 +82,12 @@ if [ $(id -u) != 0 ]; then exit 0 fi
+supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "ondemand") +if [ -z $supported ]; then + log_skip "ondemand not supported" + exit 0 +fi + save_governors
trap "restore_governors; sigtrap" SIGHUP SIGINT SIGTERM diff --git a/cpufreq/cpufreq_08.sh b/cpufreq/cpufreq_08.sh index 89be94c..e881f72 100755 --- a/cpufreq/cpufreq_08.sh +++ b/cpufreq/cpufreq_08.sh @@ -71,6 +71,12 @@ if [ $(id -u) != 0 ]; then exit 0 fi
+supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "userspace") +if [ -z $supported ]; then + log_skip "userspace not supported" + exit 0 +fi + trap "restore_governors; sigtrap" SIGHUP SIGINT SIGTERM
for_each_cpu check_userspace diff --git a/cpufreq/cpufreq_09.sh b/cpufreq/cpufreq_09.sh index 1807dc8..fc700c2 100755 --- a/cpufreq/cpufreq_09.sh +++ b/cpufreq/cpufreq_09.sh @@ -67,6 +67,12 @@ if [ $(id -u) != 0 ]; then exit 0 fi
+supported=$(cat $CPU_PATH/cpu0/cpufreq/scaling_available_governors | grep "powersave") +if [ -z $supported ]; then + log_skip "powersave not supported" + exit 0 +fi + trap "restore_governors; sigtrap" SIGHUP SIGINT SIGTERM
for_each_cpu check_powersave