]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - arch/mips/mm/tlbex.c
MIPS: tlbex: Avoid unnecessary _PAGE_PRESENT shifts
[karo-tx-linux.git] / arch / mips / mm / tlbex.c
index 97c87027c17f8bdceedb688e1df4b0e5a5f13eb9..323d1d302f2bd898372c5143c1b8c7fb2714a1ad 100644 (file)
@@ -35,7 +35,7 @@
 #include <asm/uasm.h>
 #include <asm/setup.h>
 
-static int __cpuinitdata mips_xpa_disabled;
+static int mips_xpa_disabled;
 
 static int __init xpa_disable(char *s)
 {
@@ -1608,23 +1608,32 @@ build_pte_present(u32 **p, struct uasm_reloc **r,
                  int pte, int ptr, int scratch, enum label_id lid)
 {
        int t = scratch >= 0 ? scratch : pte;
+       int cur = pte;
 
        if (cpu_has_rixi) {
                if (use_bbit_insns()) {
                        uasm_il_bbit0(p, r, pte, ilog2(_PAGE_PRESENT), lid);
                        uasm_i_nop(p);
                } else {
-                       uasm_i_srl(p, t, pte, _PAGE_PRESENT_SHIFT);
-                       uasm_i_andi(p, t, t, 1);
+                       if (_PAGE_PRESENT_SHIFT) {
+                               uasm_i_srl(p, t, cur, _PAGE_PRESENT_SHIFT);
+                               cur = t;
+                       }
+                       uasm_i_andi(p, t, cur, 1);
                        uasm_il_beqz(p, r, t, lid);
                        if (pte == t)
                                /* You lose the SMP race :-(*/
                                iPTE_LW(p, pte, ptr);
                }
        } else {
-               uasm_i_srl(p, t, pte, _PAGE_PRESENT_SHIFT);
-               uasm_i_andi(p, t, t, 3);
-               uasm_i_xori(p, t, t, 3);
+               if (_PAGE_PRESENT_SHIFT) {
+                       uasm_i_srl(p, t, cur, _PAGE_PRESENT_SHIFT);
+                       cur = t;
+               }
+               uasm_i_andi(p, t, cur,
+                       (_PAGE_PRESENT | _PAGE_READ) >> _PAGE_PRESENT_SHIFT);
+               uasm_i_xori(p, t, t,
+                       (_PAGE_PRESENT | _PAGE_READ) >> _PAGE_PRESENT_SHIFT);
                uasm_il_bnez(p, r, t, lid);
                if (pte == t)
                        /* You lose the SMP race :-(*/
@@ -1652,10 +1661,16 @@ build_pte_writable(u32 **p, struct uasm_reloc **r,
                   enum label_id lid)
 {
        int t = scratch >= 0 ? scratch : pte;
+       int cur = pte;
 
-       uasm_i_srl(p, t, pte, _PAGE_PRESENT_SHIFT);
-       uasm_i_andi(p, t, t, 5);
-       uasm_i_xori(p, t, t, 5);
+       if (_PAGE_PRESENT_SHIFT) {
+               uasm_i_srl(p, t, cur, _PAGE_PRESENT_SHIFT);
+               cur = t;
+       }
+       uasm_i_andi(p, t, cur,
+                   (_PAGE_PRESENT | _PAGE_WRITE) >> _PAGE_PRESENT_SHIFT);
+       uasm_i_xori(p, t, t,
+                   (_PAGE_PRESENT | _PAGE_WRITE) >> _PAGE_PRESENT_SHIFT);
        uasm_il_bnez(p, r, t, lid);
        if (pte == t)
                /* You lose the SMP race :-(*/