diff options
author | Thiemo Seufer <ths@networkno.de> | 2005-04-25 12:36:23 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2005-10-29 14:31:11 -0400 |
commit | ba5187dbb4b2eac99d6fa1d6bbece67e0066bf51 (patch) | |
tree | 9a1fa0b0cb6ff1c64c20569c4e6ecdfd3f865bbc /arch/mips/mm | |
parent | 7de8d2328767cf4cb463dd3ca70c44985ac835a8 (diff) |
Better interface to run uncached cache setup code.
Signed-off-by: Thiemo Seufer <ths@networkno.de>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/mm')
-rw-r--r-- | arch/mips/mm/c-r4k.c | 6 | ||||
-rw-r--r-- | arch/mips/mm/sc-rm7k.c | 29 |
2 files changed, 10 insertions, 25 deletions
diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c index 48d731c2f08a..b90147399ea4 100644 --- a/arch/mips/mm/c-r4k.c +++ b/arch/mips/mm/c-r4k.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <asm/system.h> | 26 | #include <asm/system.h> |
27 | #include <asm/mmu_context.h> | 27 | #include <asm/mmu_context.h> |
28 | #include <asm/war.h> | 28 | #include <asm/war.h> |
29 | #include <asm/cacheflush.h> /* for run_uncached() */ | ||
29 | 30 | ||
30 | static unsigned long icache_size, dcache_size, scache_size; | 31 | static unsigned long icache_size, dcache_size, scache_size; |
31 | 32 | ||
@@ -1119,7 +1120,6 @@ static int __init probe_scache(void) | |||
1119 | return 1; | 1120 | return 1; |
1120 | } | 1121 | } |
1121 | 1122 | ||
1122 | typedef int (*probe_func_t)(unsigned long); | ||
1123 | extern int r5k_sc_init(void); | 1123 | extern int r5k_sc_init(void); |
1124 | extern int rm7k_sc_init(void); | 1124 | extern int rm7k_sc_init(void); |
1125 | 1125 | ||
@@ -1127,7 +1127,6 @@ static void __init setup_scache(void) | |||
1127 | { | 1127 | { |
1128 | struct cpuinfo_mips *c = ¤t_cpu_data; | 1128 | struct cpuinfo_mips *c = ¤t_cpu_data; |
1129 | unsigned int config = read_c0_config(); | 1129 | unsigned int config = read_c0_config(); |
1130 | probe_func_t probe_scache_kseg1; | ||
1131 | int sc_present = 0; | 1130 | int sc_present = 0; |
1132 | 1131 | ||
1133 | /* | 1132 | /* |
@@ -1140,8 +1139,7 @@ static void __init setup_scache(void) | |||
1140 | case CPU_R4000MC: | 1139 | case CPU_R4000MC: |
1141 | case CPU_R4400SC: | 1140 | case CPU_R4400SC: |
1142 | case CPU_R4400MC: | 1141 | case CPU_R4400MC: |
1143 | probe_scache_kseg1 = (probe_func_t) (CKSEG1ADDR(&probe_scache)); | 1142 | sc_present = run_uncached(probe_scache); |
1144 | sc_present = probe_scache_kseg1(config); | ||
1145 | if (sc_present) | 1143 | if (sc_present) |
1146 | c->options |= MIPS_CPU_CACHE_CDEX_S; | 1144 | c->options |= MIPS_CPU_CACHE_CDEX_S; |
1147 | break; | 1145 | break; |
diff --git a/arch/mips/mm/sc-rm7k.c b/arch/mips/mm/sc-rm7k.c index 4e92f931aaba..1df5aab82c13 100644 --- a/arch/mips/mm/sc-rm7k.c +++ b/arch/mips/mm/sc-rm7k.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <asm/cacheops.h> | 15 | #include <asm/cacheops.h> |
16 | #include <asm/mipsregs.h> | 16 | #include <asm/mipsregs.h> |
17 | #include <asm/processor.h> | 17 | #include <asm/processor.h> |
18 | #include <asm/cacheflush.h> /* for run_uncached() */ | ||
18 | 19 | ||
19 | /* Primary cache parameters. */ | 20 | /* Primary cache parameters. */ |
20 | #define sc_lsize 32 | 21 | #define sc_lsize 32 |
@@ -96,25 +97,13 @@ static void rm7k_sc_inv(unsigned long addr, unsigned long size) | |||
96 | } | 97 | } |
97 | 98 | ||
98 | /* | 99 | /* |
99 | * This function is executed in the uncached segment CKSEG1. | 100 | * This function is executed in uncached address space. |
100 | * It must not touch the stack, because the stack pointer still points | ||
101 | * into CKSEG0. | ||
102 | * | ||
103 | * Three options: | ||
104 | * - Write it in assembly and guarantee that we don't use the stack. | ||
105 | * - Disable caching for CKSEG0 before calling it. | ||
106 | * - Pray that GCC doesn't randomly start using the stack. | ||
107 | * | ||
108 | * This being Linux, we obviously take the least sane of those options - | ||
109 | * following DaveM's lead in c-r4k.c | ||
110 | * | ||
111 | * It seems we get our kicks from relying on unguaranteed behaviour in GCC | ||
112 | */ | 101 | */ |
113 | static __init void __rm7k_sc_enable(void) | 102 | static __init void __rm7k_sc_enable(void) |
114 | { | 103 | { |
115 | int i; | 104 | int i; |
116 | 105 | ||
117 | set_c0_config(1 << 3); /* CONF_SE */ | 106 | set_c0_config(R7K_CONF_SE); |
118 | 107 | ||
119 | write_c0_taglo(0); | 108 | write_c0_taglo(0); |
120 | write_c0_taghi(0); | 109 | write_c0_taghi(0); |
@@ -127,24 +116,22 @@ static __init void __rm7k_sc_enable(void) | |||
127 | ".set mips0\n\t" | 116 | ".set mips0\n\t" |
128 | ".set reorder" | 117 | ".set reorder" |
129 | : | 118 | : |
130 | : "r" (KSEG0ADDR(i)), "i" (Index_Store_Tag_SD)); | 119 | : "r" (CKSEG0ADDR(i)), "i" (Index_Store_Tag_SD)); |
131 | } | 120 | } |
132 | } | 121 | } |
133 | 122 | ||
134 | static __init void rm7k_sc_enable(void) | 123 | static __init void rm7k_sc_enable(void) |
135 | { | 124 | { |
136 | void (*func)(void) = (void *) KSEG1ADDR(&__rm7k_sc_enable); | 125 | if (read_c0_config() & R7K_CONF_SE) |
137 | |||
138 | if (read_c0_config() & 0x08) /* CONF_SE */ | ||
139 | return; | 126 | return; |
140 | 127 | ||
141 | printk(KERN_INFO "Enabling secondary cache..."); | 128 | printk(KERN_INFO "Enabling secondary cache..."); |
142 | func(); | 129 | run_uncached(__rm7k_sc_enable); |
143 | } | 130 | } |
144 | 131 | ||
145 | static void rm7k_sc_disable(void) | 132 | static void rm7k_sc_disable(void) |
146 | { | 133 | { |
147 | clear_c0_config(1<<3); /* CONF_SE */ | 134 | clear_c0_config(R7K_CONF_SE); |
148 | } | 135 | } |
149 | 136 | ||
150 | struct bcache_ops rm7k_sc_ops = { | 137 | struct bcache_ops rm7k_sc_ops = { |
@@ -164,7 +151,7 @@ void __init rm7k_sc_init(void) | |||
164 | printk(KERN_INFO "Secondary cache size %dK, linesize %d bytes.\n", | 151 | printk(KERN_INFO "Secondary cache size %dK, linesize %d bytes.\n", |
165 | (scache_size >> 10), sc_lsize); | 152 | (scache_size >> 10), sc_lsize); |
166 | 153 | ||
167 | if (!((config >> 3) & 1)) /* CONF_SE */ | 154 | if (!(config & R7K_CONF_SE)) |
168 | rm7k_sc_enable(); | 155 | rm7k_sc_enable(); |
169 | 156 | ||
170 | /* | 157 | /* |