]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
powerpc/mm/hash: Add hpte_get_old_v and use that instead of opencoding
authorAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Fri, 29 Jun 2018 08:36:30 +0000 (14:06 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 24 Jul 2018 12:03:18 +0000 (22:03 +1000)
No functional change

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/book3s/64/mmu-hash.h
arch/powerpc/mm/hash_native_64.c

index 50ed64fba4ae0f17bda5f420809ed3faa40dc783..eee0b5b8a23f30137cb4324d809687dcb4228f68 100644 (file)
@@ -364,6 +364,16 @@ static inline unsigned long hpte_new_to_old_r(unsigned long r)
        return r & ~HPTE_R_3_0_SSIZE_MASK;
 }
 
+static inline unsigned long hpte_get_old_v(struct hash_pte *hptep)
+{
+       unsigned long hpte_v;
+
+       hpte_v = be64_to_cpu(hptep->v);
+       if (cpu_has_feature(CPU_FTR_ARCH_300))
+               hpte_v = hpte_new_to_old_v(hpte_v, be64_to_cpu(hptep->r));
+       return hpte_v;
+}
+
 /*
  * This function sets the AVPN and L fields of the HPTE  appropriately
  * using the base page size and actual page size.
index 1d049c78c82a957bf3346bf7269dc392f8667a99..68e6eaf41bb927e9cbc16a013d4eaa175f03af14 100644 (file)
@@ -423,9 +423,7 @@ static long native_hpte_updatepp(unsigned long slot, unsigned long newpp,
        DBG_LOW("    update(vpn=%016lx, avpnv=%016lx, group=%lx, newpp=%lx)",
                vpn, want_v & HPTE_V_AVPN, slot, newpp);
 
-       hpte_v = be64_to_cpu(hptep->v);
-       if (cpu_has_feature(CPU_FTR_ARCH_300))
-               hpte_v = hpte_new_to_old_v(hpte_v, be64_to_cpu(hptep->r));
+       hpte_v = hpte_get_old_v(hptep);
        /*
         * We need to invalidate the TLB always because hpte_remove doesn't do
         * a tlb invalidate. If a hash bucket gets full, we "evict" a more/less
@@ -439,9 +437,7 @@ static long native_hpte_updatepp(unsigned long slot, unsigned long newpp,
        } else {
                native_lock_hpte(hptep);
                /* recheck with locks held */
-               hpte_v = be64_to_cpu(hptep->v);
-               if (cpu_has_feature(CPU_FTR_ARCH_300))
-                       hpte_v = hpte_new_to_old_v(hpte_v, be64_to_cpu(hptep->r));
+               hpte_v = hpte_get_old_v(hptep);
                if (unlikely(!HPTE_V_COMPARE(hpte_v, want_v) ||
                             !(hpte_v & HPTE_V_VALID))) {
                        ret = -1;
@@ -481,11 +477,9 @@ static long native_hpte_find(unsigned long vpn, int psize, int ssize)
        /* Bolted mappings are only ever in the primary group */
        slot = (hash & htab_hash_mask) * HPTES_PER_GROUP;
        for (i = 0; i < HPTES_PER_GROUP; i++) {
-               hptep = htab_address + slot;
-               hpte_v = be64_to_cpu(hptep->v);
-               if (cpu_has_feature(CPU_FTR_ARCH_300))
-                       hpte_v = hpte_new_to_old_v(hpte_v, be64_to_cpu(hptep->r));
 
+               hptep = htab_address + slot;
+               hpte_v = hpte_get_old_v(hptep);
                if (HPTE_V_COMPARE(hpte_v, want_v) && (hpte_v & HPTE_V_VALID))
                        /* HPTE matches */
                        return slot;
@@ -575,9 +569,7 @@ static void native_hpte_invalidate(unsigned long slot, unsigned long vpn,
 
        want_v = hpte_encode_avpn(vpn, bpsize, ssize);
        native_lock_hpte(hptep);
-       hpte_v = be64_to_cpu(hptep->v);
-       if (cpu_has_feature(CPU_FTR_ARCH_300))
-               hpte_v = hpte_new_to_old_v(hpte_v, be64_to_cpu(hptep->r));
+       hpte_v = hpte_get_old_v(hptep);
 
        /*
         * We need to invalidate the TLB always because hpte_remove doesn't do
@@ -635,9 +627,7 @@ static void native_hugepage_invalidate(unsigned long vsid,
                hptep = htab_address + slot;
                want_v = hpte_encode_avpn(vpn, psize, ssize);
                native_lock_hpte(hptep);
-               hpte_v = be64_to_cpu(hptep->v);
-               if (cpu_has_feature(CPU_FTR_ARCH_300))
-                       hpte_v = hpte_new_to_old_v(hpte_v, be64_to_cpu(hptep->r));
+               hpte_v = hpte_get_old_v(hptep);
 
                /* Even if we miss, we need to invalidate the TLB */
                if (!HPTE_V_COMPARE(hpte_v, want_v) || !(hpte_v & HPTE_V_VALID))
@@ -813,10 +803,7 @@ static void native_flush_hash_range(unsigned long number, int local)
                        hptep = htab_address + slot;
                        want_v = hpte_encode_avpn(vpn, psize, ssize);
                        native_lock_hpte(hptep);
-                       hpte_v = be64_to_cpu(hptep->v);
-                       if (cpu_has_feature(CPU_FTR_ARCH_300))
-                               hpte_v = hpte_new_to_old_v(hpte_v,
-                                               be64_to_cpu(hptep->r));
+                       hpte_v = hpte_get_old_v(hptep);
                        if (!HPTE_V_COMPARE(hpte_v, want_v) ||
                            !(hpte_v & HPTE_V_VALID))
                                native_unlock_hpte(hptep);