diff options
author | Petri Savolainen <petri.savolainen@linaro.org> | 2018-06-27 17:10:16 +0300 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2018-07-05 14:59:56 +0300 |
commit | a9e3b02a54cd9a18baf8042e389ffbdb9266a9c7 (patch) | |
tree | 51092d0e1c9b2fc0f2233427b4249cc49b01b852 /platform/linux-generic/arch/x86 | |
parent | ce5951842845b519c7887479c8e4e128e1951add (diff) |
linux-gen: sysinfo: use cpufreq for max freq by default
Usually, maximum CPU frequency is found from a cpufreq file.
Read that file first, if it's not found use cpuinfo instead.
If max freq cannot be found, use hard coded value and print
a warning.
Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'platform/linux-generic/arch/x86')
-rw-r--r-- | platform/linux-generic/arch/x86/odp_sysinfo_parse.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c index f9a219752..504aa3efa 100644 --- a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c +++ b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c @@ -13,7 +13,7 @@ int cpuinfo_parser(FILE *file, system_info_t *sysinfo) { char str[1024]; - char *pos; + char *pos, *pos_end; double ghz = 0.0; uint64_t hz; int id = 0; @@ -22,17 +22,25 @@ int cpuinfo_parser(FILE *file, system_info_t *sysinfo) while (fgets(str, sizeof(str), file) != NULL && id < CONFIG_NUM_CPU) { pos = strstr(str, "model name"); if (pos) { - pos = strchr(str, ':'); + /* Copy model name between : and @ characters */ + pos = strchr(str, ':'); + pos_end = strchr(str, '@'); + if (pos == NULL || pos_end == NULL) + continue; + + *(pos_end - 1) = '\0'; strncpy(sysinfo->model_str[id], pos + 2, - sizeof(sysinfo->model_str[id]) - 1); + MODEL_STR_SIZE - 1); + + if (sysinfo->cpu_hz_max[id]) { + id++; + continue; + } - pos = strchr(sysinfo->model_str[id], '@'); - if (pos) { - *(pos - 1) = '\0'; - if (sscanf(pos, "@ %lfGHz", &ghz) == 1) { - hz = (uint64_t)(ghz * 1000000000.0); - sysinfo->cpu_hz_max[id] = hz; - } + /* max frequency needs to be set */ + if (sscanf(pos_end, "@ %lfGHz", &ghz) == 1) { + hz = (uint64_t)(ghz * 1000000000.0); + sysinfo->cpu_hz_max[id] = hz; } id++; } |