MIPS: Optimize current_cpu_type() for better code.
o Move current_cpu_type() to a separate header file o #ifdefing on supported CPU types lets modern GCC know that certain code in callers may be discarded ideally turning current_cpu_type() into a function returning a constant. o Use current_cpu_type() rather than direct access to struct cpuinfo_mips. Signed-off-by: Ralf Baechle <ralf@linux-mips.org> Cc: Steven J. Hill <Steven.Hill@imgtec.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5833/
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include <asm/bootinfo.h>
|
||||
#include <asm/cacheops.h>
|
||||
#include <asm/cpu-features.h>
|
||||
#include <asm/cpu-type.h>
|
||||
#include <asm/page.h>
|
||||
#include <asm/pgtable.h>
|
||||
#include <asm/r4kcache.h>
|
||||
@@ -186,9 +187,10 @@ static void probe_octeon(void)
|
||||
unsigned long dcache_size;
|
||||
unsigned int config1;
|
||||
struct cpuinfo_mips *c = ¤t_cpu_data;
|
||||
int cputype = current_cpu_type();
|
||||
|
||||
config1 = read_c0_config1();
|
||||
switch (c->cputype) {
|
||||
switch (cputype) {
|
||||
case CPU_CAVIUM_OCTEON:
|
||||
case CPU_CAVIUM_OCTEON_PLUS:
|
||||
c->icache.linesz = 2 << ((config1 >> 19) & 7);
|
||||
@@ -199,7 +201,7 @@ static void probe_octeon(void)
|
||||
c->icache.sets * c->icache.ways * c->icache.linesz;
|
||||
c->icache.waybit = ffs(icache_size / c->icache.ways) - 1;
|
||||
c->dcache.linesz = 128;
|
||||
if (c->cputype == CPU_CAVIUM_OCTEON_PLUS)
|
||||
if (cputype == CPU_CAVIUM_OCTEON_PLUS)
|
||||
c->dcache.sets = 2; /* CN5XXX has two Dcache sets */
|
||||
else
|
||||
c->dcache.sets = 1; /* CN3XXX has one Dcache set */
|
||||
|
Reference in New Issue
Block a user