diff mbox

cpufreq: skip frequency claimed maximum test with intel_pstate

Message ID 1460705118-13070-1-git-send-email-alex.hung@canonical.com
State Accepted
Headers show

Commit Message

Alex Hung April 15, 2016, 7:25 a.m. UTC
On SandyBridge+, intel_pstate is used and it will not provide
scaling_available_frequencies[1]. As a result, comparison fails
with following errors:

"cpu 0 has claimed frequency of 3200000, higher than max freq of 0".

[1] https://bugzilla.kernel.org/show_bug.cgi?id=57141

Signed-off-by: Alex Hung <alex.hung@canonical.com>
---
 src/cpu/cpufreq/cpufreq.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

Comments

Colin Ian King April 15, 2016, 8:28 a.m. UTC | #1
On 15/04/16 08:25, Alex Hung wrote:
> On SandyBridge+, intel_pstate is used and it will not provide
> scaling_available_frequencies[1]. As a result, comparison fails
> with following errors:
> 
> "cpu 0 has claimed frequency of 3200000, higher than max freq of 0".
> 
> [1] https://bugzilla.kernel.org/show_bug.cgi?id=57141
> 
> Signed-off-by: Alex Hung <alex.hung@canonical.com>
> ---
>  src/cpu/cpufreq/cpufreq.c | 27 ++++++++++++++++-----------
>  1 file changed, 16 insertions(+), 11 deletions(-)
> 
> diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c
> index a1cb78a..8ab5292 100644
> --- a/src/cpu/cpufreq/cpufreq.c
> +++ b/src/cpu/cpufreq/cpufreq.c
> @@ -712,6 +712,9 @@ static int cpufreq_test_claimed_max(fwts_framework *fw)
>  		if (!max)
>  			continue;
>  
> +		if (!cpu->n_freqs)
> +			continue;
> +
>  		present = true;
>  
>  		if (max > cpu->freqs[cpu->n_freqs-1].Hz) {
> @@ -778,21 +781,23 @@ static int parse_cpu_info(fwts_framework *fw,
>  	cpu_mkpath(path, sizeof(path), cpu, "scaling_available_frequencies");
>  	str = fwts_get(path);
>  
> -	for (tmp = str, i = 0; ; tmp = NULL) {
> -		char *tok = strtok(tmp, " ");
> -		if (!tok)
> -			break;
> -		if (!isdigit(tok[0]))
> -			continue;
> -		cpu->freqs[i++].Hz = strtoull(tok, NULL, 10);
> +	/* cpu driver like intel_pstate has no scaling_available_frequencies */
> +	if (str != NULL) {
> +		for (tmp = str, i = 0; ; tmp = NULL) {
> +			char *tok = strtok(tmp, " ");
> +			if (!tok)
> +				break;
> +			if (!isdigit(tok[0]))
> +				continue;
> +			cpu->freqs[i++].Hz = strtoull(tok, NULL, 10);
> +		}
> +		cpu->n_freqs = i;
> +		qsort(cpu->freqs, cpu->n_freqs, sizeof(cpu->freqs[0]),
> +			cpu_freq_compare);
>  	}
>  
>  	free(str);
>  
> -	cpu->n_freqs = i;
> -	qsort(cpu->freqs, cpu->n_freqs, sizeof(cpu->freqs[0]),
> -			cpu_freq_compare);
> -
>  	return FWTS_OK;
>  }
>  
> 
Acked-by: Colin Ian King <colin.king@canonical.com>
Ivan Hu April 19, 2016, 9:53 a.m. UTC | #2
On 2016年04月15日 15:25, Alex Hung wrote:
> On SandyBridge+, intel_pstate is used and it will not provide
> scaling_available_frequencies[1]. As a result, comparison fails
> with following errors:
>
> "cpu 0 has claimed frequency of 3200000, higher than max freq of 0".
>
> [1] https://bugzilla.kernel.org/show_bug.cgi?id=57141
>
> Signed-off-by: Alex Hung <alex.hung@canonical.com>
> ---
>   src/cpu/cpufreq/cpufreq.c | 27 ++++++++++++++++-----------
>   1 file changed, 16 insertions(+), 11 deletions(-)
>
> diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c
> index a1cb78a..8ab5292 100644
> --- a/src/cpu/cpufreq/cpufreq.c
> +++ b/src/cpu/cpufreq/cpufreq.c
> @@ -712,6 +712,9 @@ static int cpufreq_test_claimed_max(fwts_framework *fw)
>   		if (!max)
>   			continue;
>
> +		if (!cpu->n_freqs)
> +			continue;
> +
>   		present = true;
>
>   		if (max > cpu->freqs[cpu->n_freqs-1].Hz) {
> @@ -778,21 +781,23 @@ static int parse_cpu_info(fwts_framework *fw,
>   	cpu_mkpath(path, sizeof(path), cpu, "scaling_available_frequencies");
>   	str = fwts_get(path);
>
> -	for (tmp = str, i = 0; ; tmp = NULL) {
> -		char *tok = strtok(tmp, " ");
> -		if (!tok)
> -			break;
> -		if (!isdigit(tok[0]))
> -			continue;
> -		cpu->freqs[i++].Hz = strtoull(tok, NULL, 10);
> +	/* cpu driver like intel_pstate has no scaling_available_frequencies */
> +	if (str != NULL) {
> +		for (tmp = str, i = 0; ; tmp = NULL) {
> +			char *tok = strtok(tmp, " ");
> +			if (!tok)
> +				break;
> +			if (!isdigit(tok[0]))
> +				continue;
> +			cpu->freqs[i++].Hz = strtoull(tok, NULL, 10);
> +		}
> +		cpu->n_freqs = i;
> +		qsort(cpu->freqs, cpu->n_freqs, sizeof(cpu->freqs[0]),
> +			cpu_freq_compare);
>   	}
>
>   	free(str);
>
> -	cpu->n_freqs = i;
> -	qsort(cpu->freqs, cpu->n_freqs, sizeof(cpu->freqs[0]),
> -			cpu_freq_compare);
> -
>   	return FWTS_OK;
>   }
>
>

Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff mbox

Patch

diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c
index a1cb78a..8ab5292 100644
--- a/src/cpu/cpufreq/cpufreq.c
+++ b/src/cpu/cpufreq/cpufreq.c
@@ -712,6 +712,9 @@  static int cpufreq_test_claimed_max(fwts_framework *fw)
 		if (!max)
 			continue;
 
+		if (!cpu->n_freqs)
+			continue;
+
 		present = true;
 
 		if (max > cpu->freqs[cpu->n_freqs-1].Hz) {
@@ -778,21 +781,23 @@  static int parse_cpu_info(fwts_framework *fw,
 	cpu_mkpath(path, sizeof(path), cpu, "scaling_available_frequencies");
 	str = fwts_get(path);
 
-	for (tmp = str, i = 0; ; tmp = NULL) {
-		char *tok = strtok(tmp, " ");
-		if (!tok)
-			break;
-		if (!isdigit(tok[0]))
-			continue;
-		cpu->freqs[i++].Hz = strtoull(tok, NULL, 10);
+	/* cpu driver like intel_pstate has no scaling_available_frequencies */
+	if (str != NULL) {
+		for (tmp = str, i = 0; ; tmp = NULL) {
+			char *tok = strtok(tmp, " ");
+			if (!tok)
+				break;
+			if (!isdigit(tok[0]))
+				continue;
+			cpu->freqs[i++].Hz = strtoull(tok, NULL, 10);
+		}
+		cpu->n_freqs = i;
+		qsort(cpu->freqs, cpu->n_freqs, sizeof(cpu->freqs[0]),
+			cpu_freq_compare);
 	}
 
 	free(str);
 
-	cpu->n_freqs = i;
-	qsort(cpu->freqs, cpu->n_freqs, sizeof(cpu->freqs[0]),
-			cpu_freq_compare);
-
 	return FWTS_OK;
 }