forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/arch/mips/mm/tlbex.c
....@@ -28,11 +28,11 @@
2828 #include <linux/smp.h>
2929 #include <linux/string.h>
3030 #include <linux/cache.h>
31
+#include <linux/pgtable.h>
3132
3233 #include <asm/cacheflush.h>
3334 #include <asm/cpu-type.h>
3435 #include <asm/mmu_context.h>
35
-#include <asm/pgtable.h>
3636 #include <asm/war.h>
3737 #include <asm/uasm.h>
3838 #include <asm/setup.h>
....@@ -83,14 +83,18 @@
8383 return 0;
8484 }
8585
86
+extern int sb1250_m3_workaround_needed(void);
87
+
8688 static inline int __maybe_unused bcm1250_m3_war(void)
8789 {
88
- return BCM1250_M3_WAR;
90
+ if (IS_ENABLED(CONFIG_SB1_PASS_2_WORKAROUNDS))
91
+ return sb1250_m3_workaround_needed();
92
+ return 0;
8993 }
9094
9195 static inline int __maybe_unused r10000_llsc_war(void)
9296 {
93
- return R10000_LLSC_WAR;
97
+ return IS_ENABLED(CONFIG_WAR_R10000_LLSC);
9498 }
9599
96100 static int use_bbit_insns(void)
....@@ -545,7 +549,6 @@
545549 tlbw(p);
546550 break;
547551
548
- case CPU_R4300:
549552 case CPU_5KC:
550553 case CPU_TX49XX:
551554 case CPU_PR4450:
....@@ -572,11 +575,12 @@
572575 case CPU_BMIPS4350:
573576 case CPU_BMIPS4380:
574577 case CPU_BMIPS5000:
575
- case CPU_LOONGSON2:
576
- case CPU_LOONGSON3:
578
+ case CPU_LOONGSON2EF:
579
+ case CPU_LOONGSON64:
577580 case CPU_R5500:
578581 if (m4kc_tlbp_war())
579582 uasm_i_nop(p);
583
+ fallthrough;
580584 case CPU_ALCHEMY:
581585 tlbw(p);
582586 break;
....@@ -603,13 +607,12 @@
603607
604608 case CPU_VR4131:
605609 case CPU_VR4133:
606
- case CPU_R5432:
607610 uasm_i_nop(p);
608611 uasm_i_nop(p);
609612 tlbw(p);
610613 break;
611614
612
- case CPU_JZRISC:
615
+ case CPU_XBURST:
613616 tlbw(p);
614617 uasm_i_nop(p);
615618 break;
....@@ -630,7 +633,7 @@
630633 return;
631634 }
632635
633
- if (cpu_has_rixi && !!_PAGE_NO_EXEC) {
636
+ if (cpu_has_rixi && _PAGE_NO_EXEC != 0) {
634637 if (fill_includes_sw_bits) {
635638 UASM_i_ROTR(p, reg, reg, ilog2(_PAGE_GLOBAL));
636639 } else {
....@@ -943,6 +946,8 @@
943946 * to mimic that here by taking a load/istream page
944947 * fault.
945948 */
949
+ if (IS_ENABLED(CONFIG_CPU_LOONGSON3_WORKAROUNDS))
950
+ uasm_i_sync(p, 0);
946951 UASM_i_LA(p, ptr, (unsigned long)tlb_do_page_fault_0);
947952 uasm_i_jr(p, ptr);
948953
....@@ -1376,7 +1381,7 @@
13761381 switch (boot_cpu_type()) {
13771382 default:
13781383 if (sizeof(long) == 4) {
1379
- case CPU_LOONGSON2:
1384
+ case CPU_LOONGSON2EF:
13801385 /* Loongson2 ebase is different than r4k, we have more space */
13811386 if ((p - tlb_handler) > 64)
13821387 panic("TLB refill handler space exceeded");
....@@ -1666,6 +1671,8 @@
16661671 iPTE_LW(u32 **p, unsigned int pte, unsigned int ptr)
16671672 {
16681673 #ifdef CONFIG_SMP
1674
+ if (IS_ENABLED(CONFIG_CPU_LOONGSON3_WORKAROUNDS))
1675
+ uasm_i_sync(p, 0);
16691676 # ifdef CONFIG_PHYS_ADDR_T_64BIT
16701677 if (cpu_has_64bits)
16711678 uasm_i_lld(p, pte, 0, ptr);
....@@ -2279,6 +2286,8 @@
22792286 #endif
22802287
22812288 uasm_l_nopage_tlbl(&l, p);
2289
+ if (IS_ENABLED(CONFIG_CPU_LOONGSON3_WORKAROUNDS))
2290
+ uasm_i_sync(&p, 0);
22822291 build_restore_work_registers(&p);
22832292 #ifdef CONFIG_CPU_MICROMIPS
22842293 if ((unsigned long)tlb_do_page_fault_0 & 1) {
....@@ -2333,6 +2342,8 @@
23332342 #endif
23342343
23352344 uasm_l_nopage_tlbs(&l, p);
2345
+ if (IS_ENABLED(CONFIG_CPU_LOONGSON3_WORKAROUNDS))
2346
+ uasm_i_sync(&p, 0);
23362347 build_restore_work_registers(&p);
23372348 #ifdef CONFIG_CPU_MICROMIPS
23382349 if ((unsigned long)tlb_do_page_fault_1 & 1) {
....@@ -2388,6 +2399,8 @@
23882399 #endif
23892400
23902401 uasm_l_nopage_tlbm(&l, p);
2402
+ if (IS_ENABLED(CONFIG_CPU_LOONGSON3_WORKAROUNDS))
2403
+ uasm_i_sync(&p, 0);
23912404 build_restore_work_registers(&p);
23922405 #ifdef CONFIG_CPU_MICROMIPS
23932406 if ((unsigned long)tlb_do_page_fault_1 & 1) {
....@@ -2559,7 +2572,7 @@
25592572 unsigned long entry;
25602573 unsigned pabits, fillbits;
25612574
2562
- if (!cpu_has_rixi || !_PAGE_NO_EXEC) {
2575
+ if (!cpu_has_rixi || _PAGE_NO_EXEC == 0) {
25632576 /*
25642577 * We'll only be making use of the fact that we can rotate bits
25652578 * into the fill if the CPU supports RIXI, so don't bother
....@@ -2608,21 +2621,11 @@
26082621 check_for_high_segbits = current_cpu_data.vmbits > (PGDIR_SHIFT + PGD_ORDER + PAGE_SHIFT - 3);
26092622 #endif
26102623
2611
- switch (current_cpu_type()) {
2612
- case CPU_R2000:
2613
- case CPU_R3000:
2614
- case CPU_R3000A:
2615
- case CPU_R3081E:
2616
- case CPU_TX3912:
2617
- case CPU_TX3922:
2618
- case CPU_TX3927:
2624
+ if (cpu_has_3kex) {
26192625 #ifndef CONFIG_MIPS_PGD_C0_CONTEXT
2620
- if (cpu_has_local_ebase)
2621
- build_r3000_tlb_refill_handler();
26222626 if (!run_once) {
2623
- if (!cpu_has_local_ebase)
2624
- build_r3000_tlb_refill_handler();
26252627 build_setup_pgd();
2628
+ build_r3000_tlb_refill_handler();
26262629 build_r3000_tlb_load_handler();
26272630 build_r3000_tlb_store_handler();
26282631 build_r3000_tlb_modify_handler();
....@@ -2632,34 +2635,27 @@
26322635 #else
26332636 panic("No R3000 TLB refill handler");
26342637 #endif
2635
- break;
2636
-
2637
- case CPU_R8000:
2638
- panic("No R8000 TLB refill handler yet");
2639
- break;
2640
-
2641
- default:
2642
- if (cpu_has_ldpte)
2643
- setup_pw();
2644
-
2645
- if (!run_once) {
2646
- scratch_reg = allocate_kscratch();
2647
- build_setup_pgd();
2648
- build_r4000_tlb_load_handler();
2649
- build_r4000_tlb_store_handler();
2650
- build_r4000_tlb_modify_handler();
2651
- if (cpu_has_ldpte)
2652
- build_loongson3_tlb_refill_handler();
2653
- else if (!cpu_has_local_ebase)
2654
- build_r4000_tlb_refill_handler();
2655
- flush_tlb_handlers();
2656
- run_once++;
2657
- }
2658
- if (cpu_has_local_ebase)
2659
- build_r4000_tlb_refill_handler();
2660
- if (cpu_has_xpa)
2661
- config_xpa_params();
2662
- if (cpu_has_htw)
2663
- config_htw_params();
2638
+ return;
26642639 }
2640
+
2641
+ if (cpu_has_ldpte)
2642
+ setup_pw();
2643
+
2644
+ if (!run_once) {
2645
+ scratch_reg = allocate_kscratch();
2646
+ build_setup_pgd();
2647
+ build_r4000_tlb_load_handler();
2648
+ build_r4000_tlb_store_handler();
2649
+ build_r4000_tlb_modify_handler();
2650
+ if (cpu_has_ldpte)
2651
+ build_loongson3_tlb_refill_handler();
2652
+ else
2653
+ build_r4000_tlb_refill_handler();
2654
+ flush_tlb_handlers();
2655
+ run_once++;
2656
+ }
2657
+ if (cpu_has_xpa)
2658
+ config_xpa_params();
2659
+ if (cpu_has_htw)
2660
+ config_htw_params();
26652661 }