[PATCH V2] cpufreq: Add support to read boost frequencies

Shilpasri G Bhat shilpa.bhat at linux.vnet.ibm.com
Thu Apr 5 06:02:01 UTC 2018


POWER8+ and POWER9 have boost frequencies given by the cpufreq sysfs
file 'scaling_boost_frequencies'. The boost frequencies are greater
than the freqeuncies provided in 'scaling_available_frequencies'.
This patch adds support to add the boost frequencies to the list of
frequencies.

Signed-off-by: Shilpasri G Bhat <shilpa.bhat at linux.vnet.ibm.com>
---
Changes from V1:
- Remove changes from maxfreq.c which applies only for x86

 src/cpu/cpufreq/cpufreq.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c
index 8bee1dd..6cd7014 100644
--- a/src/cpu/cpufreq/cpufreq.c
+++ b/src/cpu/cpufreq/cpufreq.c
@@ -749,7 +749,7 @@ static int parse_cpu_info(fwts_framework *fw,
 {
 	char *end, path[PATH_MAX+1], *str, *tmp;
 	struct stat statbuf;
-	int rc;
+	int rc, i = 0;
 
 	strcpy(cpu->sysfs_path, dir->d_name);
 	cpu->idx = strtoul(cpu->sysfs_path + strlen("cpu"), &end, 10);
@@ -783,8 +783,6 @@ static int parse_cpu_info(fwts_framework *fw,
 
 	/* cpu driver like intel_pstate has no scaling_available_frequencies */
 	if (str != NULL) {
-		int i = 0;
-
 		for (tmp = str; ; tmp = NULL) {
 			char *tok = strtok(tmp, " ");
 			if (!tok)
@@ -800,6 +798,26 @@ static int parse_cpu_info(fwts_framework *fw,
 
 	free(str);
 
+	/* parse boost frequencies */
+	cpu_mkpath(path, sizeof(path), cpu, "scaling_boost_frequencies");
+	str = fwts_get(path);
+
+	if (str) {
+		for (tmp = str; ; 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);
 	return FWTS_OK;
 }
 
-- 
1.8.3.1




More information about the fwts-devel mailing list