aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/kernel/traps.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2007-11-08 13:02:29 -0500
committerRalf Baechle <ralf@linux-mips.org>2007-11-15 18:21:49 -0500
commitf6771dbb27c704ce837ba3bb1dcaa53f48f76ea8 (patch)
treeefec5eacc34a9e412a193a79d575cbf3b90acf23 /arch/mips/kernel/traps.c
parentefb9ca08b5a2374b29938cdcab417ce4feb14b54 (diff)
[MIPS] Fix shadow register support.
Shadow register support would not possibly have worked on multicore systems. The support code for it was also depending not on MIPS R2 but VSMP or SMTC kernels even though it makes perfect sense with UP kernels. SR sets are a scarce resource and the expected usage pattern is that users actually hardcode the register set numbers in their code. So fix the allocator by ditching it. Move the remaining CPU probe bits into the generic CPU probe. Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/kernel/traps.c')
-rw-r--r--arch/mips/kernel/traps.c68
1 files changed, 3 insertions, 65 deletions
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index fa500787152d..23e73d0650a3 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -1100,59 +1100,6 @@ void *set_except_vector(int n, void *addr)
1100 return (void *)old_handler; 1100 return (void *)old_handler;
1101} 1101}
1102 1102
1103#ifdef CONFIG_CPU_MIPSR2_SRS
1104/*
1105 * MIPSR2 shadow register set allocation
1106 * FIXME: SMP...
1107 */
1108
1109static struct shadow_registers {
1110 /*
1111 * Number of shadow register sets supported
1112 */
1113 unsigned long sr_supported;
1114 /*
1115 * Bitmap of allocated shadow registers
1116 */
1117 unsigned long sr_allocated;
1118} shadow_registers;
1119
1120static void mips_srs_init(void)
1121{
1122 shadow_registers.sr_supported = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
1123 printk(KERN_INFO "%ld MIPSR2 register sets available\n",
1124 shadow_registers.sr_supported);
1125 shadow_registers.sr_allocated = 1; /* Set 0 used by kernel */
1126}
1127
1128int mips_srs_max(void)
1129{
1130 return shadow_registers.sr_supported;
1131}
1132
1133int mips_srs_alloc(void)
1134{
1135 struct shadow_registers *sr = &shadow_registers;
1136 int set;
1137
1138again:
1139 set = find_first_zero_bit(&sr->sr_allocated, sr->sr_supported);
1140 if (set >= sr->sr_supported)
1141 return -1;
1142
1143 if (test_and_set_bit(set, &sr->sr_allocated))
1144 goto again;
1145
1146 return set;
1147}
1148
1149void mips_srs_free(int set)
1150{
1151 struct shadow_registers *sr = &shadow_registers;
1152
1153 clear_bit(set, &sr->sr_allocated);
1154}
1155
1156static asmlinkage void do_default_vi(void) 1103static asmlinkage void do_default_vi(void)
1157{ 1104{
1158 show_regs(get_irq_regs()); 1105 show_regs(get_irq_regs());
@@ -1163,6 +1110,7 @@ static void *set_vi_srs_handler(int n, vi_handler_t addr, int srs)
1163{ 1110{
1164 unsigned long handler; 1111 unsigned long handler;
1165 unsigned long old_handler = vi_handlers[n]; 1112 unsigned long old_handler = vi_handlers[n];
1113 int srssets = current_cpu_data.srsets;
1166 u32 *w; 1114 u32 *w;
1167 unsigned char *b; 1115 unsigned char *b;
1168 1116
@@ -1178,7 +1126,7 @@ static void *set_vi_srs_handler(int n, vi_handler_t addr, int srs)
1178 1126
1179 b = (unsigned char *)(ebase + 0x200 + n*VECTORSPACING); 1127 b = (unsigned char *)(ebase + 0x200 + n*VECTORSPACING);
1180 1128
1181 if (srs >= mips_srs_max()) 1129 if (srs >= srssets)
1182 panic("Shadow register set %d not supported", srs); 1130 panic("Shadow register set %d not supported", srs);
1183 1131
1184 if (cpu_has_veic) { 1132 if (cpu_has_veic) {
@@ -1186,7 +1134,7 @@ static void *set_vi_srs_handler(int n, vi_handler_t addr, int srs)
1186 board_bind_eic_interrupt(n, srs); 1134 board_bind_eic_interrupt(n, srs);
1187 } else if (cpu_has_vint) { 1135 } else if (cpu_has_vint) {
1188 /* SRSMap is only defined if shadow sets are implemented */ 1136 /* SRSMap is only defined if shadow sets are implemented */
1189 if (mips_srs_max() > 1) 1137 if (srssets > 1)
1190 change_c0_srsmap(0xf << n*4, srs << n*4); 1138 change_c0_srsmap(0xf << n*4, srs << n*4);
1191 } 1139 }
1192 1140
@@ -1253,14 +1201,6 @@ void *set_vi_handler(int n, vi_handler_t addr)
1253 return set_vi_srs_handler(n, addr, 0); 1201 return set_vi_srs_handler(n, addr, 0);
1254} 1202}
1255 1203
1256#else
1257
1258static inline void mips_srs_init(void)
1259{
1260}
1261
1262#endif /* CONFIG_CPU_MIPSR2_SRS */
1263
1264/* 1204/*
1265 * This is used by native signal handling 1205 * This is used by native signal handling
1266 */ 1206 */
@@ -1503,8 +1443,6 @@ void __init trap_init(void)
1503 else 1443 else
1504 ebase = CAC_BASE; 1444 ebase = CAC_BASE;
1505 1445
1506 mips_srs_init();
1507
1508 per_cpu_trap_init(); 1446 per_cpu_trap_init();
1509 1447
1510 /* 1448 /*