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 | |
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')
-rw-r--r-- | arch/mips/mm/c-octeon.c | 6 | ||||
-rw-r--r-- | arch/mips/mm/c-r4k.c | 14 | ||||
-rw-r--r-- | arch/mips/mm/dma-default.c | 1 | ||||
-rw-r--r-- | arch/mips/mm/page.c | 1 | ||||
-rw-r--r-- | arch/mips/mm/sc-mips.c | 3 | ||||
-rw-r--r-- | arch/mips/mm/tlb-r4k.c | 1 | ||||
-rw-r--r-- | arch/mips/mm/tlbex.c | 1 |
7 files changed, 17 insertions, 10 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 */ |
diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c index 40dced23e768..73ca8c52e83f 100644 --- a/arch/mips/mm/c-r4k.c +++ b/arch/mips/mm/c-r4k.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <asm/cacheops.h> | 25 | #include <asm/cacheops.h> |
26 | #include <asm/cpu.h> | 26 | #include <asm/cpu.h> |
27 | #include <asm/cpu-features.h> | 27 | #include <asm/cpu-features.h> |
28 | #include <asm/cpu-type.h> | ||
28 | #include <asm/io.h> | 29 | #include <asm/io.h> |
29 | #include <asm/page.h> | 30 | #include <asm/page.h> |
30 | #include <asm/pgtable.h> | 31 | #include <asm/pgtable.h> |
@@ -814,7 +815,7 @@ static void probe_pcache(void) | |||
814 | unsigned long config1; | 815 | unsigned long config1; |
815 | unsigned int lsize; | 816 | unsigned int lsize; |
816 | 817 | ||
817 | switch (c->cputype) { | 818 | switch (current_cpu_type()) { |
818 | case CPU_R4600: /* QED style two way caches? */ | 819 | case CPU_R4600: /* QED style two way caches? */ |
819 | case CPU_R4700: | 820 | case CPU_R4700: |
820 | case CPU_R5000: | 821 | case CPU_R5000: |
@@ -1050,7 +1051,7 @@ static void probe_pcache(void) | |||
1050 | * normally they'd suffer from aliases but magic in the hardware deals | 1051 | * normally they'd suffer from aliases but magic in the hardware deals |
1051 | * with that for us so we don't need to take care ourselves. | 1052 | * with that for us so we don't need to take care ourselves. |
1052 | */ | 1053 | */ |
1053 | switch (c->cputype) { | 1054 | switch (current_cpu_type()) { |
1054 | case CPU_20KC: | 1055 | case CPU_20KC: |
1055 | case CPU_25KF: | 1056 | case CPU_25KF: |
1056 | case CPU_SB1: | 1057 | case CPU_SB1: |
@@ -1070,7 +1071,7 @@ static void probe_pcache(void) | |||
1070 | case CPU_34K: | 1071 | case CPU_34K: |
1071 | case CPU_74K: | 1072 | case CPU_74K: |
1072 | case CPU_1004K: | 1073 | case CPU_1004K: |
1073 | if (c->cputype == CPU_74K) | 1074 | if (current_cpu_type() == CPU_74K) |
1074 | alias_74k_erratum(c); | 1075 | alias_74k_erratum(c); |
1075 | if ((read_c0_config7() & (1 << 16))) { | 1076 | if ((read_c0_config7() & (1 << 16))) { |
1076 | /* effectively physically indexed dcache, | 1077 | /* effectively physically indexed dcache, |
@@ -1083,7 +1084,7 @@ static void probe_pcache(void) | |||
1083 | c->dcache.flags |= MIPS_CACHE_ALIASES; | 1084 | c->dcache.flags |= MIPS_CACHE_ALIASES; |
1084 | } | 1085 | } |
1085 | 1086 | ||
1086 | switch (c->cputype) { | 1087 | switch (current_cpu_type()) { |
1087 | case CPU_20KC: | 1088 | case CPU_20KC: |
1088 | /* | 1089 | /* |
1089 | * Some older 20Kc chips doesn't have the 'VI' bit in | 1090 | * Some older 20Kc chips doesn't have the 'VI' bit in |
@@ -1212,7 +1213,7 @@ static void setup_scache(void) | |||
1212 | * processors don't have a S-cache that would be relevant to the | 1213 | * processors don't have a S-cache that would be relevant to the |
1213 | * Linux memory management. | 1214 | * Linux memory management. |
1214 | */ | 1215 | */ |
1215 | switch (c->cputype) { | 1216 | switch (current_cpu_type()) { |
1216 | case CPU_R4000SC: | 1217 | case CPU_R4000SC: |
1217 | case CPU_R4000MC: | 1218 | case CPU_R4000MC: |
1218 | case CPU_R4400SC: | 1219 | case CPU_R4400SC: |
@@ -1389,9 +1390,8 @@ static void r4k_cache_error_setup(void) | |||
1389 | { | 1390 | { |
1390 | extern char __weak except_vec2_generic; | 1391 | extern char __weak except_vec2_generic; |
1391 | extern char __weak except_vec2_sb1; | 1392 | extern char __weak except_vec2_sb1; |
1392 | struct cpuinfo_mips *c = ¤t_cpu_data; | ||
1393 | 1393 | ||
1394 | switch (c->cputype) { | 1394 | switch (current_cpu_type()) { |
1395 | case CPU_SB1: | 1395 | case CPU_SB1: |
1396 | case CPU_SB1A: | 1396 | case CPU_SB1A: |
1397 | set_uncached_handler(0x100, &except_vec2_sb1, 0x80); | 1397 | set_uncached_handler(0x100, &except_vec2_sb1, 0x80); |
diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c index 664e523653d0..f25a7e9f8cbc 100644 --- a/arch/mips/mm/dma-default.c +++ b/arch/mips/mm/dma-default.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/highmem.h> | 18 | #include <linux/highmem.h> |
19 | 19 | ||
20 | #include <asm/cache.h> | 20 | #include <asm/cache.h> |
21 | #include <asm/cpu-type.h> | ||
21 | #include <asm/io.h> | 22 | #include <asm/io.h> |
22 | 23 | ||
23 | #include <dma-coherence.h> | 24 | #include <dma-coherence.h> |
diff --git a/arch/mips/mm/page.c b/arch/mips/mm/page.c index 218c2109a55d..cbd81d17793a 100644 --- a/arch/mips/mm/page.c +++ b/arch/mips/mm/page.c | |||
@@ -18,6 +18,7 @@ | |||
18 | 18 | ||
19 | #include <asm/bugs.h> | 19 | #include <asm/bugs.h> |
20 | #include <asm/cacheops.h> | 20 | #include <asm/cacheops.h> |
21 | #include <asm/cpu-type.h> | ||
21 | #include <asm/inst.h> | 22 | #include <asm/inst.h> |
22 | #include <asm/io.h> | 23 | #include <asm/io.h> |
23 | #include <asm/page.h> | 24 | #include <asm/page.h> |
diff --git a/arch/mips/mm/sc-mips.c b/arch/mips/mm/sc-mips.c index 5d01392e3518..08d05aee8788 100644 --- a/arch/mips/mm/sc-mips.c +++ b/arch/mips/mm/sc-mips.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <linux/sched.h> | 6 | #include <linux/sched.h> |
7 | #include <linux/mm.h> | 7 | #include <linux/mm.h> |
8 | 8 | ||
9 | #include <asm/cpu-type.h> | ||
9 | #include <asm/mipsregs.h> | 10 | #include <asm/mipsregs.h> |
10 | #include <asm/bcache.h> | 11 | #include <asm/bcache.h> |
11 | #include <asm/cacheops.h> | 12 | #include <asm/cacheops.h> |
@@ -71,7 +72,7 @@ static inline int mips_sc_is_activated(struct cpuinfo_mips *c) | |||
71 | unsigned int tmp; | 72 | unsigned int tmp; |
72 | 73 | ||
73 | /* Check the bypass bit (L2B) */ | 74 | /* Check the bypass bit (L2B) */ |
74 | switch (c->cputype) { | 75 | switch (current_cpu_type()) { |
75 | case CPU_34K: | 76 | case CPU_34K: |
76 | case CPU_74K: | 77 | case CPU_74K: |
77 | case CPU_1004K: | 78 | case CPU_1004K: |
diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c index 00b26a67a06d..bb3a5f643e97 100644 --- a/arch/mips/mm/tlb-r4k.c +++ b/arch/mips/mm/tlb-r4k.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | 17 | ||
18 | #include <asm/cpu.h> | 18 | #include <asm/cpu.h> |
19 | #include <asm/cpu-type.h> | ||
19 | #include <asm/bootinfo.h> | 20 | #include <asm/bootinfo.h> |
20 | #include <asm/mmu_context.h> | 21 | #include <asm/mmu_context.h> |
21 | #include <asm/pgtable.h> | 22 | #include <asm/pgtable.h> |
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c index 821b45175dc1..9bb3a9363b06 100644 --- a/arch/mips/mm/tlbex.c +++ b/arch/mips/mm/tlbex.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/cache.h> | 30 | #include <linux/cache.h> |
31 | 31 | ||
32 | #include <asm/cacheflush.h> | 32 | #include <asm/cacheflush.h> |
33 | #include <asm/cpu-type.h> | ||
33 | #include <asm/pgtable.h> | 34 | #include <asm/pgtable.h> |
34 | #include <asm/war.h> | 35 | #include <asm/war.h> |
35 | #include <asm/uasm.h> | 36 | #include <asm/uasm.h> |