From: Kelvin Cheung <keguang.zh...@gmail.com>

When CPU frequency info under /sys is available,
use the real value instead of default value.

Signed-off-by: Kelvin Cheung <keguang.zh...@gmail.com>
Signed-off-by: Keguang Zhang <keguang.zh...@spreadtrum.com>
---
/** Email created from pull request 171 (kelvincheung:master)
 ** https://github.com/Linaro/odp/pull/171
 ** Patch: https://github.com/Linaro/odp/pull/171.patch
 ** Base sha: d6e2cd7830bd474e78980414ad7046443a4a3720
 ** Merge commit sha: b4c1e346698b9fe1d192b04c6ce6a5cf6965f3f7
 **/
 platform/linux-generic/odp_system_info.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/platform/linux-generic/odp_system_info.c 
b/platform/linux-generic/odp_system_info.c
index d6eeb786..20016358 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -310,6 +310,7 @@ static int system_hp(hugepage_info_t *hugeinfo)
  */
 int odp_system_info_init(void)
 {
+       int i;
        FILE  *file;
 
        memset(&odp_global_data.system_info, 0, sizeof(system_info_t));
@@ -326,6 +327,23 @@ int odp_system_info_init(void)
 
        fclose(file);
 
+       for (i = 0; i < MAX_CPU_NUMBER; i++) {
+               char temp[256], *endptr = NULL;
+               snprintf(temp, sizeof(temp),
+                        
"/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq",
+                        i);
+
+               file = fopen(temp, "r");
+               if (file == NULL)
+                       continue;
+
+               if (fgets(temp, sizeof(temp), file) == temp)
+                       odp_global_data.system_info.cpu_hz_max[i] =
+                           strtoull(temp, &endptr, 0);
+
+               fclose(file);
+       }
+
        if (systemcpu(&odp_global_data.system_info)) {
                ODP_ERR("systemcpu failed\n");
                return -1;

Reply via email to