From 01a310bd57bef731668d5d467c06b9646dbf28ba Mon Sep 17 00:00:00 2001 From: Juli Mallett Date: Sat, 24 Nov 2012 02:00:29 +0000 Subject: [PATCH] o) Add support for specifying a model of Octeon to target at compile-time, reducing the number of runtime checks done by the SDK code. o) Group board/CPU information at early startup by subject matter, so that e.g. CPU information is adjacent to CPU information and board information is adjacent to board information. --- sys/conf/options.mips | 1 + sys/contrib/octeon-sdk/octeon-model.c | 12 +++++++-- sys/contrib/octeon-sdk/octeon-model.h | 3 ++- sys/mips/cavium/octeon_machdep.c | 39 ++++++++++++++++++++------- sys/mips/conf/OCTEON1 | 7 +++++ 5 files changed, 49 insertions(+), 13 deletions(-) diff --git a/sys/conf/options.mips b/sys/conf/options.mips index c4b3bb75bf46..a86a749133aa 100644 --- a/sys/conf/options.mips +++ b/sys/conf/options.mips @@ -71,6 +71,7 @@ MAXMEM opt_global.h # # Options that control the Cavium Simple Executive. # +OCTEON_MODEL opt_cvmx.h OCTEON_VENDOR_LANNER opt_cvmx.h OCTEON_VENDOR_RADISYS opt_cvmx.h OCTEON_BOARD_CAPK_0100ND opt_cvmx.h diff --git a/sys/contrib/octeon-sdk/octeon-model.c b/sys/contrib/octeon-sdk/octeon-model.c index d93bf4ea24eb..ac314e4014f8 100644 --- a/sys/contrib/octeon-sdk/octeon-model.c +++ b/sys/contrib/octeon-sdk/octeon-model.c @@ -60,20 +60,24 @@ #include "cvmx-warn.h" #endif -#if defined(CVMX_BUILD_FOR_LINUX_USER) || defined(CVMX_BUILD_FOR_STANDALONE) +#if defined(CVMX_BUILD_FOR_LINUX_USER) || defined(CVMX_BUILD_FOR_STANDALONE) || defined(CVMX_BUILD_FOR_FREEBSD_KERNEL) +#if !defined(CVMX_BUILD_FOR_FREEBSD_KERNEL) #include +#endif #include "cvmx-sysinfo.h" /** * This function checks to see if the software is compatible with the * chip it is running on. This is called in the application startup code * and does not need to be called directly by the application. - * Does not return if software is incompatible. + * Does not return if software is incompatible, unless compiled for the + * FreeBSD kernel, in which case it returns -1. * * @param chip_id chip id that the software is being run on. * * @return 0: runtime checking or exact version match * 1: chip is newer revision than compiled for, but software will run properly. + * -1: software is incompatible */ int octeon_model_version_check(uint32_t chip_id __attribute__ ((unused))) { @@ -91,7 +95,11 @@ int octeon_model_version_check(uint32_t chip_id __attribute__ ((unused))) " Expecting ID=0x%08x, Chip is 0x%08x\n", (OCTEON_MODEL & 0xffffff), (unsigned int)chip_id); if ((OCTEON_MODEL & 0xffffff) > chip_id) printf("Refusing to run on older revision than program was compiled for.\n"); +#if !defined(CVMX_BUILD_FOR_FREEBSD_KERNEL) exit(-1); +#else + return(-1); +#endif } else { diff --git a/sys/contrib/octeon-sdk/octeon-model.h b/sys/contrib/octeon-sdk/octeon-model.h index 8be809eb65ac..271fca208ae8 100644 --- a/sys/contrib/octeon-sdk/octeon-model.h +++ b/sys/contrib/octeon-sdk/octeon-model.h @@ -317,7 +317,7 @@ extern "C" { ))) #ifndef OCTEON_IS_MODEL -#if defined(USE_RUNTIME_MODEL_CHECKS) || defined(__U_BOOT__) || (defined(__linux__) && defined(__KERNEL__)) || defined(CVMX_BUILD_FOR_TOOLCHAIN) || (defined(__FreeBSD__) && defined(_KERNEL)) +#if defined(USE_RUNTIME_MODEL_CHECKS) || defined(__U_BOOT__) || (defined(__linux__) && defined(__KERNEL__)) || defined(CVMX_BUILD_FOR_TOOLCHAIN) || (defined(__FreeBSD__) && defined(_KERNEL) && !defined(OCTEON_MODEL)) /* NOTE: This for internal use only!!!!! */ static inline int __octeon_is_model_runtime__(uint32_t model) @@ -359,6 +359,7 @@ static inline int __octeon_is_model_runtime__(uint32_t model) #endif #endif +int octeon_model_version_check(uint32_t chip_id); const char *octeon_model_get_string(uint32_t chip_id); const char *octeon_model_get_string_buffer(uint32_t chip_id, char * buffer); diff --git a/sys/mips/cavium/octeon_machdep.c b/sys/mips/cavium/octeon_machdep.c index 2efe43d51cfc..8bdcf749a2b1 100644 --- a/sys/mips/cavium/octeon_machdep.c +++ b/sys/mips/cavium/octeon_machdep.c @@ -276,6 +276,7 @@ platform_start(__register_t a0, __register_t a1, __register_t a2 __unused, { const struct octeon_feature_description *ofd; uint64_t platform_counter_freq; + int rv; mips_postboot_fixup(); @@ -293,19 +294,25 @@ platform_start(__register_t a0, __register_t a1, __register_t a2 __unused, cninit(); /* - * Display information about the board/CPU. + * Display information about the CPU. */ +#if !defined(OCTEON_MODEL) + printf("Using runtime CPU model checks.\n"); +#else + printf("Compiled for CPU model: " __XSTRING(OCTEON_MODEL) "\n"); +#endif + strcpy(cpu_model, octeon_model_get_string(cvmx_get_proc_id())); + printf("CPU Model: %s\n", cpu_model); printf("CPU clock: %uMHz Core Mask: %#x\n", cvmx_sysinfo_get()->cpu_clock_hz / 1000000, cvmx_sysinfo_get()->core_mask); - printf("Board Type: %u Revision: %u/%u\n", - cvmx_sysinfo_get()->board_type, - cvmx_sysinfo_get()->board_rev_major, - cvmx_sysinfo_get()->board_rev_minor); - printf("MAC address base: %6D (%u configured)\n", - cvmx_sysinfo_get()->mac_addr_base, ":", - cvmx_sysinfo_get()->mac_addr_count); + rv = octeon_model_version_check(cvmx_get_proc_id()); + if (rv == -1) + panic("%s: kernel not compatible with this processor.", __func__); + /* + * Display information about the board. + */ #if defined(OCTEON_BOARD_CAPK_0100ND) strcpy(cpu_board, "CAPK-0100ND"); if (cvmx_sysinfo_get()->board_type != CVMX_BOARD_TYPE_CN3010_EVB_HS5) { @@ -317,10 +324,22 @@ platform_start(__register_t a0, __register_t a1, __register_t a2 __unused, cvmx_board_type_to_string(cvmx_sysinfo_get()->board_type)); #endif printf("Board: %s\n", cpu_board); - strcpy(cpu_model, octeon_model_get_string(cvmx_get_proc_id())); - printf("Model: %s\n", cpu_model); + printf("Board Type: %u Revision: %u/%u\n", + cvmx_sysinfo_get()->board_type, + cvmx_sysinfo_get()->board_rev_major, + cvmx_sysinfo_get()->board_rev_minor); printf("Serial number: %s\n", cvmx_sysinfo_get()->board_serial_number); + /* + * Additional on-chip hardware/settings. + * + * XXX Display PCI host/target? What else? + */ + printf("MAC address base: %6D (%u configured)\n", + cvmx_sysinfo_get()->mac_addr_base, ":", + cvmx_sysinfo_get()->mac_addr_count); + + octeon_ciu_reset(); /* * XXX diff --git a/sys/mips/conf/OCTEON1 b/sys/mips/conf/OCTEON1 index d56351253d14..1d637d85ad70 100644 --- a/sys/mips/conf/OCTEON1 +++ b/sys/mips/conf/OCTEON1 @@ -41,6 +41,13 @@ makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols #options OCTEON_VENDOR_RADISYS # Support for Radisys boards. #options OCTEON_BOARD_CAPK_0100ND # Support for CAPK-0100nd. +# Compile for a specified Octeon model. If not specified, support for +# detection at runtime will be used instead, which may give inferior +# performance. +# +# See sys/contrib/octeon-sdk/octeon-model.h for possible values. +#options OCTEON_MODEL=OCTEON_CN58XX_PASS1_1 + options SCHED_ULE # ULE scheduler options PREEMPTION # Enable kernel thread preemption options INET # InterNETworking