From f465443f373fee431f6875b9fa826834e3890ffb Mon Sep 17 00:00:00 2001 From: wangming9 Date: Tue, 7 Nov 2023 22:25:18 +0800 Subject: [PATCH] cpuinfo: Decouple the fetch cpuinfo from up_perf_getfreq Summary: Add the default CPU frequency configuration. Signed-off-by: wangming9 Signed-off-by: lipengfei28 --- arch/Kconfig | 7 +++++++ arch/arm/src/armv6-m/arm_cpuinfo.c | 8 +++----- arch/arm/src/armv7-a/arm_cpuinfo.c | 8 +++----- arch/arm/src/armv7-m/arm_cpuinfo.c | 8 +++----- arch/arm/src/armv7-r/arm_cpuinfo.c | 8 +++----- arch/arm/src/armv8-m/arm_cpuinfo.c | 8 +++----- arch/arm/src/armv8-r/arm_cpuinfo.c | 8 +++----- arch/xtensa/src/common/xtensa_cpuinfo.c | 8 +++----- 8 files changed, 28 insertions(+), 35 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index f916feb5b7..9eb0e62783 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -528,6 +528,13 @@ config ARCH_HAVE_CPUINFO bool default n +config ARCH_CPUINFO_FREQ_KHZ + int "Default CPU frequency" + default 0 + depends on ARCH_HAVE_CPUINFO + ---help--- + Defines the CPU's default maximum frequency. Frequency unit KHZ. + config ARCH_HAVE_TCBINFO bool default n diff --git a/arch/arm/src/armv6-m/arm_cpuinfo.c b/arch/arm/src/armv6-m/arm_cpuinfo.c index da0ce987a5..d573254e1f 100644 --- a/arch/arm/src/armv6-m/arm_cpuinfo.c +++ b/arch/arm/src/armv6-m/arm_cpuinfo.c @@ -51,11 +51,9 @@ ssize_t up_show_cpuinfo(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 + procfs_sprintf(buf, buf_size, &file_off, "cpu MHz\t\t: %u.%03u\n", + CONFIG_ARCH_CPUINFO_FREQ_KHZ / 1000, + CONFIG_ARCH_CPUINFO_FREQ_KHZ % 1000); /* CPU Features */ diff --git a/arch/arm/src/armv7-a/arm_cpuinfo.c b/arch/arm/src/armv7-a/arm_cpuinfo.c index ea5c19c1bc..c39923e4e3 100644 --- a/arch/arm/src/armv7-a/arm_cpuinfo.c +++ b/arch/arm/src/armv7-a/arm_cpuinfo.c @@ -73,11 +73,9 @@ ssize_t up_show_cpuinfo(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 + procfs_sprintf(buf, buf_size, &file_off, "cpu MHz\t\t: %u.%03u\n", + CONFIG_ARCH_CPUINFO_FREQ_KHZ / 1000, + CONFIG_ARCH_CPUINFO_FREQ_KHZ % 1000); /* CPU Features */ diff --git a/arch/arm/src/armv7-m/arm_cpuinfo.c b/arch/arm/src/armv7-m/arm_cpuinfo.c index 7f05f28749..58063d1e52 100644 --- a/arch/arm/src/armv7-m/arm_cpuinfo.c +++ b/arch/arm/src/armv7-m/arm_cpuinfo.c @@ -70,11 +70,9 @@ ssize_t up_show_cpuinfo(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 + procfs_sprintf(buf, buf_size, &file_off, "cpu MHz\t\t: %u.%03u\n", + CONFIG_ARCH_CPUINFO_FREQ_KHZ / 1000, + CONFIG_ARCH_CPUINFO_FREQ_KHZ % 1000); /* CPU Features */ diff --git a/arch/arm/src/armv7-r/arm_cpuinfo.c b/arch/arm/src/armv7-r/arm_cpuinfo.c index e1514ae324..790def5277 100644 --- a/arch/arm/src/armv7-r/arm_cpuinfo.c +++ b/arch/arm/src/armv7-r/arm_cpuinfo.c @@ -73,11 +73,9 @@ ssize_t up_show_cpuinfo(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 + procfs_sprintf(buf, buf_size, &file_off, "cpu MHz\t\t: %u.%03u\n", + CONFIG_ARCH_CPUINFO_FREQ_KHZ / 1000, + CONFIG_ARCH_CPUINFO_FREQ_KHZ % 1000); /* CPU Features */ diff --git a/arch/arm/src/armv8-m/arm_cpuinfo.c b/arch/arm/src/armv8-m/arm_cpuinfo.c index 814ff97fbb..0e5b4c7b59 100644 --- a/arch/arm/src/armv8-m/arm_cpuinfo.c +++ b/arch/arm/src/armv8-m/arm_cpuinfo.c @@ -74,11 +74,9 @@ ssize_t up_show_cpuinfo(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 + procfs_sprintf(buf, buf_size, &file_off, "cpu MHz\t\t: %u.%03u\n", + CONFIG_ARCH_CPUINFO_FREQ_KHZ / 1000, + CONFIG_ARCH_CPUINFO_FREQ_KHZ % 1000); /* Cpu features */ diff --git a/arch/arm/src/armv8-r/arm_cpuinfo.c b/arch/arm/src/armv8-r/arm_cpuinfo.c index 38767b47f7..2be9f40c14 100644 --- a/arch/arm/src/armv8-r/arm_cpuinfo.c +++ b/arch/arm/src/armv8-r/arm_cpuinfo.c @@ -73,11 +73,9 @@ ssize_t up_show_cpuinfo(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 + procfs_sprintf(buf, buf_size, &file_off, "cpu MHz\t\t: %u.%03u\n", + CONFIG_ARCH_CPUINFO_FREQ_KHZ / 1000, + CONFIG_ARCH_CPUINFO_FREQ_KHZ % 1000); /* CPU Features */ diff --git a/arch/xtensa/src/common/xtensa_cpuinfo.c b/arch/xtensa/src/common/xtensa_cpuinfo.c index a7dc94203e..c15f8fe6d2 100644 --- a/arch/xtensa/src/common/xtensa_cpuinfo.c +++ b/arch/xtensa/src/common/xtensa_cpuinfo.c @@ -105,11 +105,9 @@ ssize_t up_show_cpuinfo(char *buf, size_t buf_size, off_t file_off) (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 + procfs_sprintf(buf, buf_size, &file_off, "cpu MHz\t\t: %u.%03u\n", + CONFIG_ARCH_CPUINFO_FREQ_KHZ / 1000, + CONFIG_ARCH_CPUINFO_FREQ_KHZ % 1000); /* Features */