aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Uvarov <maxim.uvarov@linaro.org>2018-11-13 12:17:47 +0300
committerMaxim Uvarov <maxim.uvarov@linaro.org>2018-11-14 18:17:02 +0300
commit1c1118ee10c209bac716f9368bbbbd47a74b62ef (patch)
tree8b6c311bee8548009616cd872f61faa1cd19c268
parent7c7194c3da746e435044829fcd1f38b8011e386d (diff)
downloadodp-master.tar.gz
linux-gen: run without /proc mountedHEADmaster
Some systems may have /proc interface not mounted, let odp linux generic run there with dummy values. https://bugs.linaro.org/show_bug.cgi?id=3989 Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
-rw-r--r--platform/linux-generic/arch/aarch64/odp_sysinfo_parse.c1
-rw-r--r--platform/linux-generic/arch/default/odp_sysinfo_parse.c16
-rw-r--r--platform/linux-generic/arch/x86/odp_sysinfo_parse.c2
-rw-r--r--platform/linux-generic/include/odp_sysinfo_internal.h19
-rw-r--r--platform/linux-generic/odp_system_info.c17
5 files changed, 31 insertions, 24 deletions
diff --git a/platform/linux-generic/arch/aarch64/odp_sysinfo_parse.c b/platform/linux-generic/arch/aarch64/odp_sysinfo_parse.c
index 85aec6a6..bcdc2373 100644
--- a/platform/linux-generic/arch/aarch64/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/aarch64/odp_sysinfo_parse.c
@@ -12,7 +12,6 @@
#include <odp_sysinfo_internal.h>
#include <odp_debug_internal.h>
-#define DUMMY_MAX_MHZ 1000
#define TMP_STR_LEN 64
static void aarch64_impl_str(char *str, int maxlen, int implementer)
diff --git a/platform/linux-generic/arch/default/odp_sysinfo_parse.c b/platform/linux-generic/arch/default/odp_sysinfo_parse.c
index b9378887..da3f2eb3 100644
--- a/platform/linux-generic/arch/default/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/default/odp_sysinfo_parse.c
@@ -7,24 +7,10 @@
#include "config.h"
#include <odp_sysinfo_internal.h>
-#include <odp_debug_internal.h>
-#include <string.h>
-
-#define DUMMY_MAX_MHZ 1400
int cpuinfo_parser(FILE *file ODP_UNUSED, system_info_t *sysinfo)
{
- int i;
-
- ODP_DBG("Warning: use dummy values for freq and model string\n");
- for (i = 0; i < CONFIG_NUM_CPU; i++) {
- ODP_PRINT("WARN: cpu[%i] uses dummy max frequency %u MHz\n",
- i, DUMMY_MAX_MHZ);
- sysinfo->cpu_hz_max[i] = DUMMY_MAX_MHZ * 1000000;
- strcpy(sysinfo->model_str[i], "UNKNOWN");
- }
-
- return 0;
+ return _odp_dummy_cpuinfo(sysinfo);
}
void sys_info_print_arch(void)
diff --git a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
index 5084e6b5..7124e84f 100644
--- a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
@@ -83,6 +83,8 @@ uint64_t odp_cpu_arch_hz_current(int id)
double mhz = 0.0;
file = fopen("/proc/cpuinfo", "rt");
+ if (!file)
+ return 0;
/* find the correct processor instance */
while (fgets(str, sizeof(str), file) != NULL) {
diff --git a/platform/linux-generic/include/odp_sysinfo_internal.h b/platform/linux-generic/include/odp_sysinfo_internal.h
index 2f01d18e..49254230 100644
--- a/platform/linux-generic/include/odp_sysinfo_internal.h
+++ b/platform/linux-generic/include/odp_sysinfo_internal.h
@@ -12,12 +12,31 @@ extern "C" {
#endif
#include <odp_global_data.h>
+#include <odp_debug_internal.h>
+#include <string.h>
+
+#define DUMMY_MAX_MHZ 1400
int cpuinfo_parser(FILE *file, system_info_t *sysinfo);
uint64_t odp_cpu_hz_current(int id);
uint64_t odp_cpu_arch_hz_current(int id);
void sys_info_print_arch(void);
+static inline int _odp_dummy_cpuinfo(system_info_t *sysinfo)
+{
+ int i;
+
+ ODP_DBG("Warning: use dummy values for freq and model string\n");
+ for (i = 0; i < CONFIG_NUM_CPU; i++) {
+ ODP_PRINT("WARN: cpu[%i] uses dummy max frequency %u MHz\n",
+ i, DUMMY_MAX_MHZ);
+ sysinfo->cpu_hz_max[i] = DUMMY_MAX_MHZ * 1000000;
+ strcpy(sysinfo->model_str[i], "UNKNOWN");
+ }
+
+ return 0;
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c
index 733c3528..a7a78d27 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -96,6 +96,8 @@ static uint64_t default_huge_page_size(void)
FILE *file;
file = fopen("/proc/meminfo", "rt");
+ if (!file)
+ return 0;
while (fgets(str, sizeof(str), file) != NULL) {
if (sscanf(str, "Hugepagesize: %8lu kB", &sz) == 1) {
@@ -352,16 +354,15 @@ int odp_system_info_init(void)
}
file = fopen("/proc/cpuinfo", "rt");
- if (file == NULL) {
- ODP_ERR("Failed to open /proc/cpuinfo\n");
- return -1;
+ if (file != NULL) {
+ /* Read CPU model, and set max cpu frequency
+ * if not set from cpufreq. */
+ cpuinfo_parser(file, &odp_global_ro.system_info);
+ fclose(file);
+ } else {
+ _odp_dummy_cpuinfo(&odp_global_ro.system_info);
}
- /* Read CPU model, and set max cpu frequency if not set from cpufreq. */
- cpuinfo_parser(file, &odp_global_ro.system_info);
-
- fclose(file);
-
if (systemcpu(&odp_global_ro.system_info)) {
ODP_ERR("systemcpu failed\n");
return -1;