Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / arch / mips / mm / pg-r4k.c
index 9f8b165..b7c7492 100644 (file)
 #include <asm/cpu.h>
 #include <asm/war.h>
 
-#define half_scache_line_size()                (cpu_scache_line_size() >> 1)
+#define half_scache_line_size()        (cpu_scache_line_size() >> 1)
+#define cpu_is_r4600_v1_x()    ((read_c0_prid() & 0xfffffff0) == 0x00002010)
+#define cpu_is_r4600_v2_x()    ((read_c0_prid() & 0xfffffff0) == 0x00002020)
+
 
 /*
  * Maximum sizes:
@@ -121,7 +124,7 @@ static inline void build_nop(void)
 
 static inline void build_src_pref(int advance)
 {
-       if (!(load_offset & (cpu_dcache_line_size() - 1))) {
+       if (!(load_offset & (cpu_dcache_line_size() - 1)) && advance) {
                union mips_instruction mi;
 
                mi.i_format.opcode     = pref_op;
@@ -163,7 +166,7 @@ static inline void build_load_reg(int reg)
 
 static inline void build_dst_pref(int advance)
 {
-       if (!(store_offset & (cpu_dcache_line_size() - 1))) {
+       if (!(store_offset & (cpu_dcache_line_size() - 1)) && advance) {
                union mips_instruction mi;
 
                mi.i_format.opcode     = pref_op;
@@ -198,15 +201,15 @@ static inline void build_cdex_p(void)
        if (store_offset & (cpu_dcache_line_size() - 1))
                return;
 
-       if (R4600_V1_HIT_CACHEOP_WAR && ((read_c0_prid() & 0xfff0) == 0x2010)) {
+       if (R4600_V1_HIT_CACHEOP_WAR && cpu_is_r4600_v1_x()) {
                build_nop();
                build_nop();
                build_nop();
                build_nop();
        }
 
-       if (R4600_V2_HIT_CACHEOP_WAR && ((read_c0_prid() & 0xfff0) == 0x2020))
-               build_insn_word(0x8c200000);    /* lw      $zero, ($at) */
+       if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x())
+               build_insn_word(0x3c01a000);    /* lui     $at, 0xa000  */
 
        mi.c_format.opcode     = cache_op;
        mi.c_format.rs         = 4;             /* $a0 */
@@ -337,6 +340,12 @@ void __init build_clear_page(void)
 
        if (cpu_has_prefetch) {
                switch (current_cpu_data.cputype) {
+               case CPU_TX49XX:
+                       /* TX49 supports only Pref_Load */
+                       pref_offset_clear = 0;
+                       pref_offset_copy = 0;
+                       break;
+
                case CPU_RM9000:
                        /*
                         * As a workaround for erratum G105 which make the
@@ -348,6 +357,7 @@ void __init build_clear_page(void)
 
                case CPU_R10000:
                case CPU_R12000:
+               case CPU_R14000:
                        pref_src_mode = Pref_LoadStreamed;
                        pref_dst_mode = Pref_StoreStreamed;
                        break;
@@ -361,7 +371,7 @@ void __init build_clear_page(void)
 
        build_addiu_a2_a0(PAGE_SIZE - (cpu_has_prefetch ? pref_offset_clear : 0));
 
-       if (R4600_V2_HIT_CACHEOP_WAR && ((read_c0_prid() & 0xfff0) == 0x2020))
+       if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x())
                build_insn_word(0x3c01a000);    /* lui     $at, 0xa000  */
 
 dest = label();
@@ -404,9 +414,6 @@ dest = label();
 
        build_jr_ra();
 
-       flush_icache_range((unsigned long)&clear_page_array,
-                          (unsigned long) epc);
-
        BUG_ON(epc > clear_page_array + ARRAY_SIZE(clear_page_array));
 }
 
@@ -420,7 +427,7 @@ void __init build_copy_page(void)
 
        build_addiu_a2_a0(PAGE_SIZE - (cpu_has_prefetch ? pref_offset_copy : 0));
 
-       if (R4600_V2_HIT_CACHEOP_WAR && ((read_c0_prid() & 0xfff0) == 0x2020))
+       if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x())
                build_insn_word(0x3c01a000);    /* lui     $at, 0xa000  */
 
 dest = label();
@@ -482,8 +489,5 @@ dest = label();
 
        build_jr_ra();
 
-       flush_icache_range((unsigned long)&copy_page_array,
-                          (unsigned long) epc);
-
        BUG_ON(epc > copy_page_array + ARRAY_SIZE(copy_page_array));
 }