···346346347347static inline void local_r4k___flush_cache_all(void * args)348348{349349-#if defined(CONFIG_CPU_LOONGSON2)350350- r4k_blast_scache();351351- return;352352-#endif353353- r4k_blast_dcache();354354- r4k_blast_icache();355355-356349 switch (current_cpu_type()) {350350+ case CPU_LOONGSON2:357351 case CPU_R4000SC:358352 case CPU_R4000MC:359353 case CPU_R4400SC:···355361 case CPU_R10000:356362 case CPU_R12000:357363 case CPU_R14000:364364+ /*365365+ * These caches are inclusive caches, that is, if something366366+ * is not cached in the S-cache, we know it also won't be367367+ * in one of the primary caches.368368+ */358369 r4k_blast_scache();370370+ break;371371+372372+ default:373373+ r4k_blast_dcache();374374+ r4k_blast_icache();375375+ break;359376 }360377}361378···577572578573 if (end - start > icache_size)579574 r4k_blast_icache();580580- else581581- protected_blast_icache_range(start, end);575575+ else {576576+ switch (boot_cpu_type()) {577577+ case CPU_LOONGSON2:578578+ protected_blast_icache_range(start, end);579579+ break;580580+581581+ default:582582+ protected_loongson23_blast_icache_range(start, end);583583+ break;584584+ }585585+ }582586}583587584588static inline void local_r4k_flush_icache_range_ipi(void *args)···11231109 case CPU_ALCHEMY:11241110 c->icache.flags |= MIPS_CACHE_IC_F_DC;11251111 break;11261126- }1127111211281128-#ifdef CONFIG_CPU_LOONGSON211291129- /*11301130- * LOONGSON2 has 4 way icache, but when using indexed cache op,11311131- * one op will act on all 4 ways11321132- */11331133- c->icache.ways = 1;11341134-#endif11131113+ case CPU_LOONGSON2:11141114+ /*11151115+ * LOONGSON2 has 4 way icache, but when using indexed cache op,11161116+ * one op will act on all 4 ways11171117+ */11181118+ c->icache.ways = 1;11191119+ }1135112011361121 printk("Primary instruction cache %ldkB, %s, %s, linesize %d bytes.\n",11371122 icache_size >> 10,···12061193 return 1;12071194}1208119512091209-#if defined(CONFIG_CPU_LOONGSON2)12101196static void __init loongson2_sc_init(void)12111197{12121198 struct cpuinfo_mips *c = ¤t_cpu_data;···1221120912221210 c->options |= MIPS_CPU_INCLUSIVE_CACHES;12231211}12241224-#endif1225121212261213extern int r5k_sc_init(void);12271214extern int rm7k_sc_init(void);···12701259#endif12711260 return;1272126112731273-#if defined(CONFIG_CPU_LOONGSON2)12741262 case CPU_LOONGSON2:12751263 loongson2_sc_init();12761264 return;12771277-#endif12651265+12781266 case CPU_XLP:12791267 /* don't need to worry about L2, fully coherent */12801268 return;
+21-16
arch/mips/mm/tlb-r4k.c
···52525353#endif /* CONFIG_MIPS_MT_SMTC */54545555-#if defined(CONFIG_CPU_LOONGSON2)5655/*5756 * LOONGSON2 has a 4 entry itlb which is a subset of dtlb,5857 * unfortrunately, itlb is not totally transparent to software.5958 */6060-#define FLUSH_ITLB write_c0_diag(4);5959+static inline void flush_itlb(void)6060+{6161+ switch (current_cpu_type()) {6262+ case CPU_LOONGSON2:6363+ write_c0_diag(4);6464+ break;6565+ default:6666+ break;6767+ }6868+}61696262-#define FLUSH_ITLB_VM(vma) { if ((vma)->vm_flags & VM_EXEC) write_c0_diag(4); }6363-6464-#else6565-6666-#define FLUSH_ITLB6767-#define FLUSH_ITLB_VM(vma)6868-6969-#endif7070+static inline void flush_itlb_vm(struct vm_area_struct *vma)7171+{7272+ if (vma->vm_flags & VM_EXEC)7373+ flush_itlb();7474+}70757176void local_flush_tlb_all(void)7277{···9893 }9994 tlbw_use_hazard();10095 write_c0_entryhi(old_ctx);101101- FLUSH_ITLB;9696+ flush_itlb();10297 EXIT_CRITICAL(flags);10398}10499EXPORT_SYMBOL(local_flush_tlb_all);···160155 } else {161156 drop_mmu_context(mm, cpu);162157 }163163- FLUSH_ITLB;158158+ flush_itlb();164159 EXIT_CRITICAL(flags);165160 }166161}···202197 } else {203198 local_flush_tlb_all();204199 }205205- FLUSH_ITLB;200200+ flush_itlb();206201 EXIT_CRITICAL(flags);207202}208203···235230236231 finish:237232 write_c0_entryhi(oldpid);238238- FLUSH_ITLB_VM(vma);233233+ flush_itlb_vm(vma);239234 EXIT_CRITICAL(flags);240235 }241236}···267262 tlbw_use_hazard();268263 }269264 write_c0_entryhi(oldpid);270270- FLUSH_ITLB;265265+ flush_itlb();271266 EXIT_CRITICAL(flags);272267}273268···340335 tlb_write_indexed();341336 }342337 tlbw_use_hazard();343343- FLUSH_ITLB_VM(vma);338338+ flush_itlb_vm(vma);344339 EXIT_CRITICAL(flags);345340}346341
+83-78
arch/mips/mm/tlbex.c
···13111311 * need three, with the second nop'ed and the third being13121312 * unused.13131313 */13141314- /* Loongson2 ebase is different than r4k, we have more space */13151315-#if defined(CONFIG_32BIT) || defined(CONFIG_CPU_LOONGSON2)13161316- if ((p - tlb_handler) > 64)13171317- panic("TLB refill handler space exceeded");13181318-#else13191319- if (((p - tlb_handler) > (MIPS64_REFILL_INSNS * 2) - 1)13201320- || (((p - tlb_handler) > (MIPS64_REFILL_INSNS * 2) - 3)13211321- && uasm_insn_has_bdelay(relocs,13221322- tlb_handler + MIPS64_REFILL_INSNS - 3)))13231323- panic("TLB refill handler space exceeded");13241324-#endif13251325-13261326- /*13271327- * Now fold the handler in the TLB refill handler space.13281328- */13291329-#if defined(CONFIG_32BIT) || defined(CONFIG_CPU_LOONGSON2)13301330- f = final_handler;13311331- /* Simplest case, just copy the handler. */13321332- uasm_copy_handler(relocs, labels, tlb_handler, p, f);13331333- final_len = p - tlb_handler;13341334-#else /* CONFIG_64BIT */13351335- f = final_handler + MIPS64_REFILL_INSNS;13361336- if ((p - tlb_handler) <= MIPS64_REFILL_INSNS) {13371337- /* Just copy the handler. */13381338- uasm_copy_handler(relocs, labels, tlb_handler, p, f);13391339- final_len = p - tlb_handler;13401340- } else {13141314+ switch (boot_cpu_type()) {13151315+ default:13161316+ if (sizeof(long) == 4) {13171317+ case CPU_LOONGSON2:13181318+ /* Loongson2 ebase is different than r4k, we have more space */13191319+ if ((p - tlb_handler) > 64)13201320+ panic("TLB refill handler space exceeded");13211321+ /*13221322+ * Now fold the handler in the TLB refill handler space.13231323+ */13241324+ f = final_handler;13251325+ /* Simplest case, just copy the handler. */13261326+ uasm_copy_handler(relocs, labels, tlb_handler, p, f);13271327+ final_len = p - tlb_handler;13281328+ break;13291329+ } else {13301330+ if (((p - tlb_handler) > (MIPS64_REFILL_INSNS * 2) - 1)13311331+ || (((p - tlb_handler) > (MIPS64_REFILL_INSNS * 2) - 3)13321332+ && uasm_insn_has_bdelay(relocs,13331333+ tlb_handler + MIPS64_REFILL_INSNS - 3)))13341334+ panic("TLB refill handler space exceeded");13351335+ /*13361336+ * Now fold the handler in the TLB refill handler space.13371337+ */13381338+ f = final_handler + MIPS64_REFILL_INSNS;13391339+ if ((p - tlb_handler) <= MIPS64_REFILL_INSNS) {13401340+ /* Just copy the handler. */13411341+ uasm_copy_handler(relocs, labels, tlb_handler, p, f);13421342+ final_len = p - tlb_handler;13431343+ } else {13411344#ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT13421342- const enum label_id ls = label_tlb_huge_update;13451345+ const enum label_id ls = label_tlb_huge_update;13431346#else13441344- const enum label_id ls = label_vmalloc;13471347+ const enum label_id ls = label_vmalloc;13451348#endif13461346- u32 *split;13471347- int ov = 0;13481348- int i;13491349+ u32 *split;13501350+ int ov = 0;13511351+ int i;1349135213501350- for (i = 0; i < ARRAY_SIZE(labels) && labels[i].lab != ls; i++)13511351- ;13521352- BUG_ON(i == ARRAY_SIZE(labels));13531353- split = labels[i].addr;13531353+ for (i = 0; i < ARRAY_SIZE(labels) && labels[i].lab != ls; i++)13541354+ ;13551355+ BUG_ON(i == ARRAY_SIZE(labels));13561356+ split = labels[i].addr;1354135713551355- /*13561356- * See if we have overflown one way or the other.13571357- */13581358- if (split > tlb_handler + MIPS64_REFILL_INSNS ||13591359- split < p - MIPS64_REFILL_INSNS)13601360- ov = 1;13581358+ /*13591359+ * See if we have overflown one way or the other.13601360+ */13611361+ if (split > tlb_handler + MIPS64_REFILL_INSNS ||13621362+ split < p - MIPS64_REFILL_INSNS)13631363+ ov = 1;1361136413621362- if (ov) {13631363- /*13641364- * Split two instructions before the end. One13651365- * for the branch and one for the instruction13661366- * in the delay slot.13671367- */13681368- split = tlb_handler + MIPS64_REFILL_INSNS - 2;13651365+ if (ov) {13661366+ /*13671367+ * Split two instructions before the end. One13681368+ * for the branch and one for the instruction13691369+ * in the delay slot.13701370+ */13711371+ split = tlb_handler + MIPS64_REFILL_INSNS - 2;1369137213701370- /*13711371- * If the branch would fall in a delay slot,13721372- * we must back up an additional instruction13731373- * so that it is no longer in a delay slot.13741374- */13751375- if (uasm_insn_has_bdelay(relocs, split - 1))13761376- split--;13771377- }13781378- /* Copy first part of the handler. */13791379- uasm_copy_handler(relocs, labels, tlb_handler, split, f);13801380- f += split - tlb_handler;13731373+ /*13741374+ * If the branch would fall in a delay slot,13751375+ * we must back up an additional instruction13761376+ * so that it is no longer in a delay slot.13771377+ */13781378+ if (uasm_insn_has_bdelay(relocs, split - 1))13791379+ split--;13801380+ }13811381+ /* Copy first part of the handler. */13821382+ uasm_copy_handler(relocs, labels, tlb_handler, split, f);13831383+ f += split - tlb_handler;1381138413821382- if (ov) {13831383- /* Insert branch. */13841384- uasm_l_split(&l, final_handler);13851385- uasm_il_b(&f, &r, label_split);13861386- if (uasm_insn_has_bdelay(relocs, split))13871387- uasm_i_nop(&f);13881388- else {13891389- uasm_copy_handler(relocs, labels,13901390- split, split + 1, f);13911391- uasm_move_labels(labels, f, f + 1, -1);13921392- f++;13931393- split++;13851385+ if (ov) {13861386+ /* Insert branch. */13871387+ uasm_l_split(&l, final_handler);13881388+ uasm_il_b(&f, &r, label_split);13891389+ if (uasm_insn_has_bdelay(relocs, split))13901390+ uasm_i_nop(&f);13911391+ else {13921392+ uasm_copy_handler(relocs, labels,13931393+ split, split + 1, f);13941394+ uasm_move_labels(labels, f, f + 1, -1);13951395+ f++;13961396+ split++;13971397+ }13981398+ }13991399+14001400+ /* Copy the rest of the handler. */14011401+ uasm_copy_handler(relocs, labels, split, p, final_handler);14021402+ final_len = (f - (final_handler + MIPS64_REFILL_INSNS)) +14031403+ (p - split);13941404 }13951405 }13961396-13971397- /* Copy the rest of the handler. */13981398- uasm_copy_handler(relocs, labels, split, p, final_handler);13991399- final_len = (f - (final_handler + MIPS64_REFILL_INSNS)) +14001400- (p - split);14061406+ break;14011407 }14021402-#endif /* CONFIG_64BIT */1403140814041409 uasm_resolve_relocs(relocs, labels);14051410 pr_debug("Wrote TLB refill handler (%u instructions).\n",