diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2013-09-17 04:25:47 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2013-09-17 12:50:53 -0400 |
commit | 69f24d1784b631b81a54eb57c49bf46536dd2382 (patch) | |
tree | 93c05469adbeb6bd24ab06b11d5f906a879e2c11 /arch/mips/mm/c-octeon.c | |
parent | ff522058bd717506b2fa066fa564657f2b86477e (diff) |
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/
Diffstat (limited to 'arch/mips/mm/c-octeon.c')
-rw-r--r-- | arch/mips/mm/c-octeon.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/arch/mips/mm/c-octeon.c b/arch/mips/mm/c-octeon.c index 729e7702b1de..c8efdb5b6ee0 100644 --- a/arch/mips/mm/c-octeon.c +++ b/arch/mips/mm/c-octeon.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <asm/bootinfo.h> | 19 | #include <asm/bootinfo.h> |
20 | #include <asm/cacheops.h> | 20 | #include <asm/cacheops.h> |
21 | #include <asm/cpu-features.h> | 21 | #include <asm/cpu-features.h> |
22 | #include <asm/cpu-type.h> | ||
22 | #include <asm/page.h> | 23 | #include <asm/page.h> |
23 | #include <asm/pgtable.h> | 24 | #include <asm/pgtable.h> |
24 | #include <asm/r4kcache.h> | 25 | #include <asm/r4kcache.h> |
@@ -186,9 +187,10 @@ static void probe_octeon(void) | |||
186 | unsigned long dcache_size; | 187 | unsigned long dcache_size; |
187 | unsigned int config1; | 188 | unsigned int config1; |
188 | struct cpuinfo_mips *c = ¤t_cpu_data; | 189 | struct cpuinfo_mips *c = ¤t_cpu_data; |
190 | int cputype = current_cpu_type(); | ||
189 | 191 | ||
190 | config1 = read_c0_config1(); | 192 | config1 = read_c0_config1(); |
191 | switch (c->cputype) { | 193 | switch (cputype) { |
192 | case CPU_CAVIUM_OCTEON: | 194 | case CPU_CAVIUM_OCTEON: |
193 | case CPU_CAVIUM_OCTEON_PLUS: | 195 | case CPU_CAVIUM_OCTEON_PLUS: |
194 | c->icache.linesz = 2 << ((config1 >> 19) & 7); | 196 | c->icache.linesz = 2 << ((config1 >> 19) & 7); |
@@ -199,7 +201,7 @@ static void probe_octeon(void) | |||
199 | c->icache.sets * c->icache.ways * c->icache.linesz; | 201 | c->icache.sets * c->icache.ways * c->icache.linesz; |
200 | c->icache.waybit = ffs(icache_size / c->icache.ways) - 1; | 202 | c->icache.waybit = ffs(icache_size / c->icache.ways) - 1; |
201 | c->dcache.linesz = 128; | 203 | c->dcache.linesz = 128; |
202 | if (c->cputype == CPU_CAVIUM_OCTEON_PLUS) | 204 | if (cputype == CPU_CAVIUM_OCTEON_PLUS) |
203 | c->dcache.sets = 2; /* CN5XXX has two Dcache sets */ | 205 | c->dcache.sets = 2; /* CN5XXX has two Dcache sets */ |
204 | else | 206 | else |
205 | c->dcache.sets = 1; /* CN3XXX has one Dcache set */ | 207 | c->dcache.sets = 1; /* CN3XXX has one Dcache set */ |