MIPS: OCTEON: cvmx_fuse_read_byte cleanup
PATCH 2/4 MIPS: OCTEON: delete potentially dangerous feature checks
In reply to Aaro KoskinenWe should not need to read fuses during normal operation, also the current code has issues with that (not safe for concurrent access). Since there are no in-kernel users for these, just delete them. Drivers should not need such OCTEON_HAS_FEATURE mechanism in any case, instead the information should be passed via device tree.
--- arch/mips/include/asm/octeon/cvmx.h | 43 ---------------------- arch/mips/include/asm/octeon/octeon-feature.h | 52 --------------------------- 2 files changed, 95 deletions(-)
arch/mips/include/asm/octeon/cvmx.h +0 -43
@@ -453,47 +453,4 @@ static inline uint32_t cvmx_octeon_num_cores(void)uint8_t cvmx_fuse_read_byte (int byte_addr); -/** -* Read a single fuse bit -* -* @fuse: Fuse number (0-1024) -* -* Returns fuse value: 0 or 1 -*/ -static inline int cvmx_fuse_read (int fuse) -{ -return (cvmx_fuse_read_byte (fuse >>3 ) >> (fuse &0x7 )) &1 ; -} - -static inline int cvmx_octeon_model_CN36XX (void ) -{ -return OCTEON_IS_MODEL (OCTEON_CN38XX ) - && !cvmx_octeon_is_pass1 () - &&cvmx_fuse_read (264 ); -} - -static inline int cvmx_octeon_zip_present (void ) -{ -return octeon_has_feature (OCTEON_FEATURE_ZIP ); -} - -static inline int cvmx_octeon_dfa_present (void ) -{ -if (!OCTEON_IS_MODEL (OCTEON_CN38XX ) - && !OCTEON_IS_MODEL (OCTEON_CN31XX ) - && !OCTEON_IS_MODEL (OCTEON_CN58XX )) -return 0 ; -else if (OCTEON_IS_MODEL (OCTEON_CN3020 )) -return 0 ; -else if (cvmx_octeon_is_pass1 ()) -return 1 ; -else -return !cvmx_fuse_read (120 ); -} - -static inline int cvmx_octeon_crypto_present (void ) -{ -return octeon_has_feature (OCTEON_FEATURE_CRYPTO ); -} -#endif /* __CVMX_H__ */
arch/mips/include/asm/octeon/octeon-feature.h +0 -52
70 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH 1/4 MIPS: OCTEON: move cvmx_fuse_read_byte()
In reply to Aaro KoskinenMove cvmx_fuse_read_byte() into a .c file.
--- arch/mips/cavium-octeon/executive/octeon-model.c | 20 ++++++++++++++++++++ arch/mips/include/asm/octeon/cvmx.h | 20 +------------------- 2 files changed, 21 insertions(+), 19 deletions(-)
arch/mips/cavium-octeon/executive/octeon-model.c +20 -0
@@ -28,6 +28,26 @@#include <asm/octeon/octeon.h> /** +* Read a byte of fuse data +* @byte_addr: address to read +* +* Returns fuse value: 0 or 1 +*/ +uint8_t cvmx_fuse_read_byte (int byte_addr) +{ +union cvmx_mio_fus_rcmd read_cmd; + + read_cmd.u64 =0 ; + read_cmd.s.addr = byte_addr; + read_cmd.s.pend =1 ; +cvmx_write_csr (CVMX_MIO_FUS_RCMD , read_cmd.u64); +while ((read_cmd.u64 =cvmx_read_csr (CVMX_MIO_FUS_RCMD )) + && read_cmd.s.pend) + ; +return read_cmd.s.dat; +} + +/** * Given the chip processor ID from COP0, this function returns a * string representing the chip model number. The string is of the * form CNXXXXpX.X-FREQ-SUFFIX.
arch/mips/include/asm/octeon/cvmx.h +1 -19
@@ -451,25 +451,7 @@ static inline uint32_t cvmx_octeon_num_cores(void)return cvmx_pop (ciu_fuse); } -/** -* Read a byte of fuse data -* @byte_addr: address to read -* -* Returns fuse value: 0 or 1 -*/ -static uint8_t cvmx_fuse_read_byte (int byte_addr) -{ -union cvmx_mio_fus_rcmd read_cmd; - - read_cmd.u64 =0 ; - read_cmd.s.addr = byte_addr; - read_cmd.s.pend =1 ; -cvmx_write_csr (CVMX_MIO_FUS_RCMD , read_cmd.u64); -while ((read_cmd.u64 =cvmx_read_csr (CVMX_MIO_FUS_RCMD )) - && read_cmd.s.pend) - ; -return read_cmd.s.dat; -} +uint8_t cvmx_fuse_read_byte (int byte_addr);/** * Read a single fuse bit
Signature · 1 line
2.1.0
cover MIPS: OCTEON: cvmx_fuse_read_byte cleanup
Hi,
Here's a small cleanup to follow up the /proc/cpuinfo fix, and eliminates the possibility of cvmx_fuse_read_byte completely after the kernel has completed the init.
Aaro Koskinen (4):
MIPS: OCTEON: move cvmx_fuse_read_byte()
MIPS: OCTEON: delete potentially dangerous feature checks
MIPS: OCTEON: move code to avoid forward declaration
MIPS: OCTEON: mark octeon_model_get_string() with __init
arch/mips/cavium-octeon/executive/octeon-model.c | 49 ++++++++++++------ arch/mips/include/asm/octeon/cvmx.h | 63 ------------------------ arch/mips/include/asm/octeon/octeon-feature.h | 52 ------------------- arch/mips/include/asm/octeon/octeon-model.h | 3 +- 4 files changed, 36 insertions(+), 131 deletions(-)
Signature · 1 line
2.1.0
PATCH 3/4 MIPS: OCTEON: move code to avoid forward declaration
Move code to avoid forward declarations.
--- arch/mips/cavium-octeon/executive/octeon-model.c | 38 ++++++++++++------------ 1 file changed, 19 insertions(+), 19 deletions(-)
arch/mips/cavium-octeon/executive/octeon-model.c +19 -19
@@ -47,25 +47,6 @@ uint8_t cvmx_fuse_read_byte(int byte_addr)return read_cmd.s.dat; } -/** -* Given the chip processor ID from COP0, this function returns a -* string representing the chip model number. The string is of the -* form CNXXXXpX.X-FREQ-SUFFIX. -* - XXXX = The chip model number -* - X.X = Chip pass number -* - FREQ = Current frequency in Mhz -* - SUFFIX = NSP, EXP, SCP, SSP, or CP -* -* @chip_id: Chip ID -* -* Returns Model string -*/ -const char *octeon_model_get_string (uint32_t chip_id) -{ -static char buffer[32 ]; -return octeon_model_get_string_buffer (chip_id, buffer); -} -/* * Version of octeon_model_get_string() that takes buffer as argument, * as running early in u-boot static/global variables don't work when
@@ -427,3 +408,22 @@ const char *octeon_model_get_string_buffer(uint32_t chip_id, char *buffer)sprintf (buffer,"CN%s%sp%s-%d-%s" , family, core_model, pass, clock_mhz, suffix);return buffer; } + +/** +* Given the chip processor ID from COP0, this function returns a +* string representing the chip model number. The string is of the +* form CNXXXXpX.X-FREQ-SUFFIX. +* - XXXX = The chip model number +* - X.X = Chip pass number +* - FREQ = Current frequency in Mhz +* - SUFFIX = NSP, EXP, SCP, SSP, or CP +* +* @chip_id: Chip ID +* +* Returns Model string +*/ +const char *octeon_model_get_string (uint32_t chip_id) +{ +static char buffer[32 ]; +return octeon_model_get_string_buffer (chip_id, buffer); +}
Signature · 1 line
2.1.0
PATCH 4/4 MIPS: OCTEON: mark octeon_model_get_string() with __init
In reply to Aaro KoskinenMark octeon_model_get_string() with __init and make internal functions static.
--- arch/mips/cavium-octeon/executive/octeon-model.c | 7 ++++--- arch/mips/include/asm/octeon/cvmx.h | 2 -- arch/mips/include/asm/octeon/octeon-model.h | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-)
arch/mips/cavium-octeon/executive/octeon-model.c +4 -3
@@ -33,7 +33,7 @@* * Returns fuse value: 0 or 1 */ -uint8_t cvmx_fuse_read_byte (int byte_addr) +static uint8_t __init cvmx_fuse_read_byte (int byte_addr) {union cvmx_mio_fus_rcmd read_cmd;
@@ -52,7 +52,8 @@ uint8_t cvmx_fuse_read_byte(int byte_addr)* as running early in u-boot static/global variables don't work when * running from flash. */ -const char *octeon_model_get_string_buffer (uint32_t chip_id,char *buffer) +static const char *__init octeon_model_get_string_buffer (uint32_t chip_id, +char *buffer) {const char *family;const char *core_model;
@@ -422,7 +423,7 @@ const char *octeon_model_get_string_buffer(uint32_t chip_id, char *buffer)* * Returns Model string */ -const char *octeon_model_get_string (uint32_t chip_id) +const char *__init octeon_model_get_string (uint32_t chip_id) {static char buffer[32 ];return octeon_model_get_string_buffer (chip_id, buffer);
arch/mips/include/asm/octeon/cvmx.h +0 -2
@@ -451,6 +451,4 @@ static inline uint32_t cvmx_octeon_num_cores(void) return cvmx_pop(ciu_fuse); } -uint8_t cvmx_fuse_read_byte (int byte_addr); -#endif /* __CVMX_H__ */
arch/mips/include/asm/octeon/octeon-model.h +1 -2
@@ -326,8 +326,7 @@ static inline int __octeon_is_model_runtime__(uint32_t model)#define OCTEON_IS_COMMON_BINARY () 1#undef OCTEON_MODEL -const char *octeon_model_get_string (uint32_t chip_id); -const char *octeon_model_get_string_buffer (uint32_t chip_id,char *buffer); +const char *__init octeon_model_get_string (uint32_t chip_id);/* * Return the octeon family, i.e., ProcessorID of the PrID register.
Signature · 1 line
2.1.0