Patchwork [2/2] cpufreq: fix the CPUFreqSW_ALL and CPUFreqSW_ANY failed LP#1076694

login
register
mail settings
Submitter Ivan Hu
Date Nov. 20, 2012, 10:10 a.m.
Message ID <1353406242-31089-1-git-send-email-ivan.hu@canonical.com>
Download mbox | patch
Permalink /patch/200282/
State Accepted
Headers show

Comments

Ivan Hu - Nov. 20, 2012, 10:10 a.m.
The tests will set frequency to 0 that causes test fail, modify the
get_performance_repeat fuction to avoid the test fail.

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/cpu/cpufreq/cpufreq.c |   21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
Colin King - Nov. 20, 2012, 10:53 a.m.
On 20/11/12 10:10, Ivan Hu wrote:
> The tests will set frequency to 0 that causes test fail, modify the
> get_performance_repeat fuction to avoid the test fail.

I think we've been bitten by a change in functionality in the way 
setting the lowest frequency works, or this is a bug from the original 
code from the linux firmware kit where this code was derived.

>
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>   src/cpu/cpufreq/cpufreq.c |   21 +++++++++------------
>   1 file changed, 9 insertions(+), 12 deletions(-)
>
> diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c
> index 98a5a9a..7136e7d 100644
> --- a/src/cpu/cpufreq/cpufreq.c
> +++ b/src/cpu/cpufreq/cpufreq.c
> @@ -172,9 +172,7 @@ static unsigned long get_performance(const int cpu)
>   	return loopcount;
>   }
>
> -
> -static unsigned long get_performance_repeat(fwts_framework *fw,
> -	int cpu, unsigned long Hz, int count, int type)
> +static unsigned long get_performance_repeat(int cpu, int count, int type)
>   {
>   	int i;
>
> @@ -182,7 +180,6 @@ static unsigned long get_performance_repeat(fwts_framework *fw,
>   	unsigned long long cumulative = 0;
>   	unsigned long retval;
>
> -	set_HZ(fw, cpu, Hz);

Yes, this is redundant (and wrong). Well spotted. This bug has been here 
since day #1 of this test.

>   	for (i = 0; i < count; i++) {
>   		unsigned long temp;
>   		temp = get_performance(cpu);
> @@ -468,11 +465,11 @@ static void do_sw_all_test(fwts_framework *fw)
>   	closedir(dir);
>
>   	/* All CPUs at the lowest frequency */
> -	lowperf = 100 * get_performance_repeat(fw, first_cpu_index,
> -						0, 5, GET_PERFORMANCE_MIN) / top_speed;
> +	lowperf = 100 * get_performance_repeat(first_cpu_index,
> +						5, GET_PERFORMANCE_MIN) / top_speed;
>   	highest_speed(fw, first_cpu_index);
> -	highperf = 100 * get_performance_repeat(fw, first_cpu_index,
> -						0, 5, GET_PERFORMANCE_MAX) / top_speed;
> +	highperf = 100 * get_performance_repeat(first_cpu_index,
> +						5, GET_PERFORMANCE_MAX) / top_speed;
>
>   	if (lowperf >= highperf)
>   		fwts_failed(fw, LOG_LEVEL_MEDIUM,
> @@ -515,8 +512,8 @@ static void do_sw_any_test(fwts_framework *fw)
>   	rewinddir(dir);
>
>   	/* All CPUs at the lowest frequency */
> -	lowperf = 100 * get_performance_repeat(fw, first_cpu_index,
> -						0, 5, GET_PERFORMANCE_MIN) / top_speed;
> +	lowperf = 100 * get_performance_repeat(first_cpu_index,
> +						5, GET_PERFORMANCE_MIN) / top_speed;
>
>   	highest_speed(fw, first_cpu_index);
>
> @@ -530,8 +527,8 @@ static void do_sw_any_test(fwts_framework *fw)
>   	}
>   	closedir(dir);
>
> -	highperf = 100 * get_performance_repeat(fw, first_cpu_index,
> -						0, 5, GET_PERFORMANCE_MAX) / top_speed;
> +	highperf = 100 * get_performance_repeat(first_cpu_index,
> +						5, GET_PERFORMANCE_MAX) / top_speed;
>
>   	if (lowperf >= highperf)
>   		fwts_failed(fw, LOG_LEVEL_MEDIUM,
>

Thanks Ivan.

Acked-by: Colin Ian King <colin.king@canonical.com>
Alex Hung - Nov. 22, 2012, 2:28 a.m.
On 11/20/2012 06:10 PM, Ivan Hu wrote:
> The tests will set frequency to 0 that causes test fail, modify the
> get_performance_repeat fuction to avoid the test fail.
>
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>   src/cpu/cpufreq/cpufreq.c |   21 +++++++++------------
>   1 file changed, 9 insertions(+), 12 deletions(-)
>
> diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c
> index 98a5a9a..7136e7d 100644
> --- a/src/cpu/cpufreq/cpufreq.c
> +++ b/src/cpu/cpufreq/cpufreq.c
> @@ -172,9 +172,7 @@ static unsigned long get_performance(const int cpu)
>   	return loopcount;
>   }
>
> -
> -static unsigned long get_performance_repeat(fwts_framework *fw,
> -	int cpu, unsigned long Hz, int count, int type)
> +static unsigned long get_performance_repeat(int cpu, int count, int type)
>   {
>   	int i;
>
> @@ -182,7 +180,6 @@ static unsigned long get_performance_repeat(fwts_framework *fw,
>   	unsigned long long cumulative = 0;
>   	unsigned long retval;
>
> -	set_HZ(fw, cpu, Hz);
>   	for (i = 0; i < count; i++) {
>   		unsigned long temp;
>   		temp = get_performance(cpu);
> @@ -468,11 +465,11 @@ static void do_sw_all_test(fwts_framework *fw)
>   	closedir(dir);
>
>   	/* All CPUs at the lowest frequency */
> -	lowperf = 100 * get_performance_repeat(fw, first_cpu_index,
> -						0, 5, GET_PERFORMANCE_MIN) / top_speed;
> +	lowperf = 100 * get_performance_repeat(first_cpu_index,
> +						5, GET_PERFORMANCE_MIN) / top_speed;
>   	highest_speed(fw, first_cpu_index);
> -	highperf = 100 * get_performance_repeat(fw, first_cpu_index,
> -						0, 5, GET_PERFORMANCE_MAX) / top_speed;
> +	highperf = 100 * get_performance_repeat(first_cpu_index,
> +						5, GET_PERFORMANCE_MAX) / top_speed;
>
>   	if (lowperf >= highperf)
>   		fwts_failed(fw, LOG_LEVEL_MEDIUM,
> @@ -515,8 +512,8 @@ static void do_sw_any_test(fwts_framework *fw)
>   	rewinddir(dir);
>
>   	/* All CPUs at the lowest frequency */
> -	lowperf = 100 * get_performance_repeat(fw, first_cpu_index,
> -						0, 5, GET_PERFORMANCE_MIN) / top_speed;
> +	lowperf = 100 * get_performance_repeat(first_cpu_index,
> +						5, GET_PERFORMANCE_MIN) / top_speed;
>
>   	highest_speed(fw, first_cpu_index);
>
> @@ -530,8 +527,8 @@ static void do_sw_any_test(fwts_framework *fw)
>   	}
>   	closedir(dir);
>
> -	highperf = 100 * get_performance_repeat(fw, first_cpu_index,
> -						0, 5, GET_PERFORMANCE_MAX) / top_speed;
> +	highperf = 100 * get_performance_repeat(first_cpu_index,
> +						5, GET_PERFORMANCE_MAX) / top_speed;
>
>   	if (lowperf >= highperf)
>   		fwts_failed(fw, LOG_LEVEL_MEDIUM,
>
Acked-by: Alex Hung <alex.hung@canonical.com>

Patch

diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c
index 98a5a9a..7136e7d 100644
--- a/src/cpu/cpufreq/cpufreq.c
+++ b/src/cpu/cpufreq/cpufreq.c
@@ -172,9 +172,7 @@  static unsigned long get_performance(const int cpu)
 	return loopcount;
 }
 
-
-static unsigned long get_performance_repeat(fwts_framework *fw,
-	int cpu, unsigned long Hz, int count, int type)
+static unsigned long get_performance_repeat(int cpu, int count, int type)
 {
 	int i;
 
@@ -182,7 +180,6 @@  static unsigned long get_performance_repeat(fwts_framework *fw,
 	unsigned long long cumulative = 0;
 	unsigned long retval;
 
-	set_HZ(fw, cpu, Hz);
 	for (i = 0; i < count; i++) {
 		unsigned long temp;
 		temp = get_performance(cpu);
@@ -468,11 +465,11 @@  static void do_sw_all_test(fwts_framework *fw)
 	closedir(dir);
 
 	/* All CPUs at the lowest frequency */
-	lowperf = 100 * get_performance_repeat(fw, first_cpu_index,
-						0, 5, GET_PERFORMANCE_MIN) / top_speed;
+	lowperf = 100 * get_performance_repeat(first_cpu_index,
+						5, GET_PERFORMANCE_MIN) / top_speed;
 	highest_speed(fw, first_cpu_index);
-	highperf = 100 * get_performance_repeat(fw, first_cpu_index,
-						0, 5, GET_PERFORMANCE_MAX) / top_speed;
+	highperf = 100 * get_performance_repeat(first_cpu_index,
+						5, GET_PERFORMANCE_MAX) / top_speed;
 
 	if (lowperf >= highperf)
 		fwts_failed(fw, LOG_LEVEL_MEDIUM,
@@ -515,8 +512,8 @@  static void do_sw_any_test(fwts_framework *fw)
 	rewinddir(dir);
 
 	/* All CPUs at the lowest frequency */
-	lowperf = 100 * get_performance_repeat(fw, first_cpu_index,
-						0, 5, GET_PERFORMANCE_MIN) / top_speed;
+	lowperf = 100 * get_performance_repeat(first_cpu_index,
+						5, GET_PERFORMANCE_MIN) / top_speed;
 
 	highest_speed(fw, first_cpu_index);
 
@@ -530,8 +527,8 @@  static void do_sw_any_test(fwts_framework *fw)
 	}
 	closedir(dir);
 
-	highperf = 100 * get_performance_repeat(fw, first_cpu_index,
-						0, 5, GET_PERFORMANCE_MAX) / top_speed;
+	highperf = 100 * get_performance_repeat(first_cpu_index,
+						5, GET_PERFORMANCE_MAX) / top_speed;
 
 	if (lowperf >= highperf)
 		fwts_failed(fw, LOG_LEVEL_MEDIUM,