From c31e869fac26b6ebbe9b9bf87fa5bdc0edd01e38 Mon Sep 17 00:00:00 2001 From: liaoao Date: Fri, 18 Aug 2023 10:33:00 +0800 Subject: [PATCH] cpuinfo: show cpufreq when hardware perfermance counting enabled Signed-off-by: liaoao --- arch/arm/src/armv6-m/arm_cpuinfo.c | 2 ++ arch/arm/src/armv7-a/arm_cpuinfo.c | 2 ++ arch/arm/src/armv7-m/arm_cpuinfo.c | 2 ++ arch/arm/src/armv7-r/arm_cpuinfo.c | 2 ++ arch/arm/src/armv8-m/arm_cpuinfo.c | 2 ++ arch/arm/src/armv8-r/arm_cpuinfo.c | 2 ++ arch/xtensa/src/common/xtensa_cpuinfo.c | 9 ++++++--- 7 files changed, 18 insertions(+), 3 deletions(-) diff --git a/arch/arm/src/armv6-m/arm_cpuinfo.c b/arch/arm/src/armv6-m/arm_cpuinfo.c index 13d0995fa3..83b76a39e4 100644 --- a/arch/arm/src/armv6-m/arm_cpuinfo.c +++ b/arch/arm/src/armv6-m/arm_cpuinfo.c @@ -51,9 +51,11 @@ ssize_t up_show_cpuinfo(FAR char *buf, size_t buf_size, off_t file_off) procfs_sprintf(buf, buf_size, &file_off, "BogoMIPS\t: %u.%02u\n", (CONFIG_BOARD_LOOPSPERMSEC / 1000), (CONFIG_BOARD_LOOPSPERMSEC / 10) % 100); +#if defined(CONFIG_ARCH_PERF_EVENTS) procfs_sprintf(buf, buf_size, &file_off, "cpu MHz\t\t: %lu.%02lu\n", up_perf_getfreq() / 1000000, (up_perf_getfreq() / 10000) % 100); +#endif /* CPU Features */ diff --git a/arch/arm/src/armv7-a/arm_cpuinfo.c b/arch/arm/src/armv7-a/arm_cpuinfo.c index cc1b0e3508..9c9552d773 100644 --- a/arch/arm/src/armv7-a/arm_cpuinfo.c +++ b/arch/arm/src/armv7-a/arm_cpuinfo.c @@ -72,9 +72,11 @@ ssize_t up_show_cpuinfo(FAR char *buf, size_t buf_size, off_t file_off) procfs_sprintf(buf, buf_size, &file_off, "BogoMIPS\t: %u.%02u\n", (CONFIG_BOARD_LOOPSPERMSEC / 1000), (CONFIG_BOARD_LOOPSPERMSEC / 10) % 100); +#if defined(CONFIG_ARCH_PERF_EVENTS) procfs_sprintf(buf, buf_size, &file_off, "cpu MHz\t\t: %lu.%02lu\n", up_perf_getfreq() / 1000000, (up_perf_getfreq() / 10000) % 100); +#endif /* CPU Features */ diff --git a/arch/arm/src/armv7-m/arm_cpuinfo.c b/arch/arm/src/armv7-m/arm_cpuinfo.c index 0b677e651e..6d8fbb8450 100644 --- a/arch/arm/src/armv7-m/arm_cpuinfo.c +++ b/arch/arm/src/armv7-m/arm_cpuinfo.c @@ -70,9 +70,11 @@ ssize_t up_show_cpuinfo(FAR char *buf, size_t buf_size, off_t file_off) procfs_sprintf(buf, buf_size, &file_off, "BogoMIPS\t: %u.%02u\n", (CONFIG_BOARD_LOOPSPERMSEC / 1000), (CONFIG_BOARD_LOOPSPERMSEC / 10) % 100); +#if defined(CONFIG_ARCH_PERF_EVENTS) procfs_sprintf(buf, buf_size, &file_off, "cpu MHz\t\t: %lu.%02lu\n", up_perf_getfreq() / 1000000, (up_perf_getfreq() / 10000) % 100); +#endif /* CPU Features */ diff --git a/arch/arm/src/armv7-r/arm_cpuinfo.c b/arch/arm/src/armv7-r/arm_cpuinfo.c index 522729b46f..5137d0b582 100644 --- a/arch/arm/src/armv7-r/arm_cpuinfo.c +++ b/arch/arm/src/armv7-r/arm_cpuinfo.c @@ -72,9 +72,11 @@ ssize_t up_show_cpuinfo(FAR char *buf, size_t buf_size, off_t file_off) procfs_sprintf(buf, buf_size, &file_off, "BogoMIPS\t: %u.%02u\n", (CONFIG_BOARD_LOOPSPERMSEC / 1000), (CONFIG_BOARD_LOOPSPERMSEC / 10) % 100); +#if defined(CONFIG_ARCH_PERF_EVENTS) procfs_sprintf(buf, buf_size, &file_off, "cpu MHz\t\t: %lu.%02lu\n", up_perf_getfreq() / 1000000, (up_perf_getfreq() / 10000) % 100); +#endif /* CPU Features */ diff --git a/arch/arm/src/armv8-m/arm_cpuinfo.c b/arch/arm/src/armv8-m/arm_cpuinfo.c index 0022f5259d..79e9051951 100644 --- a/arch/arm/src/armv8-m/arm_cpuinfo.c +++ b/arch/arm/src/armv8-m/arm_cpuinfo.c @@ -74,9 +74,11 @@ ssize_t up_show_cpuinfo(FAR char *buf, size_t buf_size, off_t file_off) procfs_sprintf(buf, buf_size, &file_off, "BogoMIPS\t: %u.%02u\n", (CONFIG_BOARD_LOOPSPERMSEC / 1000), (CONFIG_BOARD_LOOPSPERMSEC / 10) % 100); +#if defined(CONFIG_ARCH_PERF_EVENTS) procfs_sprintf(buf, buf_size, &file_off, "cpu MHz\t\t: %lu.%02lu\n", up_perf_getfreq() / 1000000, (up_perf_getfreq() / 10000) % 100); +#endif /* Cpu features */ diff --git a/arch/arm/src/armv8-r/arm_cpuinfo.c b/arch/arm/src/armv8-r/arm_cpuinfo.c index af53a31719..920f057e7e 100644 --- a/arch/arm/src/armv8-r/arm_cpuinfo.c +++ b/arch/arm/src/armv8-r/arm_cpuinfo.c @@ -72,9 +72,11 @@ ssize_t up_show_cpuinfo(FAR char *buf, size_t buf_size, off_t file_off) procfs_sprintf(buf, buf_size, &file_off, "BogoMIPS\t: %u.%02u\n", (CONFIG_BOARD_LOOPSPERMSEC / 1000), (CONFIG_BOARD_LOOPSPERMSEC / 10) % 100); +#if defined(CONFIG_ARCH_PERF_EVENTS) procfs_sprintf(buf, buf_size, &file_off, "cpu MHz\t\t: %lu.%02lu\n", up_perf_getfreq() / 1000000, (up_perf_getfreq() / 10000) % 100); +#endif /* CPU Features */ diff --git a/arch/xtensa/src/common/xtensa_cpuinfo.c b/arch/xtensa/src/common/xtensa_cpuinfo.c index 147f0d32c0..2aab9a4b14 100644 --- a/arch/xtensa/src/common/xtensa_cpuinfo.c +++ b/arch/xtensa/src/common/xtensa_cpuinfo.c @@ -100,14 +100,17 @@ ssize_t up_show_cpuinfo(FAR char *buf, size_t buf_size, off_t file_off) procfs_sprintf(buf, buf_size, &file_off, "byte order\t: %s\n" - "cpu MHz\t\t: %lu.%02lu\n" "bogomips\t: %u.%02u\n", XCHAL_HAVE_BE ? "big" : "little", - up_perf_getfreq() / 1000000, - (up_perf_getfreq() / 10000) % 100, (CONFIG_BOARD_LOOPSPERMSEC / 1000), (CONFIG_BOARD_LOOPSPERMSEC / 10) % 100); +#if defined(CONFIG_ARCH_PERF_EVENTS) + procfs_sprintf(buf, buf_size, &file_off, "cpu MHz\t\t: %lu.%02lu\n", + up_perf_getfreq() / 1000000, + (up_perf_getfreq() / 10000) % 100); +#endif + /* Features */ procfs_sprintf(buf, buf_size, &file_off, "flags\t\t: "