Signed-off-by: Aneesh Kumar K.V <aneesh.ku...@linux.vnet.ibm.com>
---
 arch/powerpc/mm/hash_native_64.c      | 28 ++++++++--------------------
 arch/powerpc/platforms/pseries/lpar.c | 13 ++++---------
 2 files changed, 12 insertions(+), 29 deletions(-)

diff --git a/arch/powerpc/mm/hash_native_64.c b/arch/powerpc/mm/hash_native_64.c
index ce25e125dd06..c3fdd684a287 100644
--- a/arch/powerpc/mm/hash_native_64.c
+++ b/arch/powerpc/mm/hash_native_64.c
@@ -702,10 +702,8 @@ static void native_hpte_clear(void)
 static void native_flush_hash_range(unsigned long number, int local)
 {
        unsigned long vpn;
-       unsigned long hash, index, hidx, shift, slot;
+       unsigned long hash, index, shift;
        struct hash_pte *hptep;
-       unsigned long hpte_v;
-       unsigned long want_v;
        unsigned long flags;
        real_pte_t pte;
        struct ppc64_tlb_batch *batch = this_cpu_ptr(&ppc64_tlb_batch);
@@ -725,23 +723,13 @@ static void native_flush_hash_range(unsigned long number, 
int local)
 
                pte_iterate_hashed_subpages(pte, psize, vpn, index, shift) {
                        hash = hpt_hash(vpn, shift, ssize);
-                       hidx = __rpte_to_hidx(pte, index);
-                       if (hidx & _PTEIDX_SECONDARY)
-                               hash = ~hash;
-                       slot = (hash & htab_hash_mask) * HPTES_PER_GROUP;
-                       slot += hidx & _PTEIDX_GROUP_IX;
-                       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));
-                       if (!HPTE_V_COMPARE(hpte_v, want_v) ||
-                           !(hpte_v & HPTE_V_VALID))
-                               native_unlock_hpte(hptep);
-                       else
-                               hptep->v = 0;
+                       hptep = native_hpte_find(hash, vpn, psize, ssize);
+                       if (!hptep)
+                               continue;
+                       /*
+                        * Invalidate the hpte. NOTE: this also unlocks it
+                        */
+                       hptep->v = 0;
                } pte_iterate_hashed_end();
        }
 
diff --git a/arch/powerpc/platforms/pseries/lpar.c 
b/arch/powerpc/platforms/pseries/lpar.c
index e366252e0e93..ad7838171bb0 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -580,14 +580,14 @@ static int pSeries_lpar_hpte_removebolted(unsigned long 
ea,
 static void pSeries_lpar_flush_hash_range(unsigned long number, int local)
 {
        unsigned long vpn;
-       unsigned long i, pix, rc;
+       unsigned long i, rc;
        unsigned long flags = 0;
        struct ppc64_tlb_batch *batch = this_cpu_ptr(&ppc64_tlb_batch);
        int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE);
        unsigned long param[PLPAR_HCALL9_BUFSIZE];
-       unsigned long hash, index, shift, hidx, slot;
+       unsigned long index, shift, slot;
        real_pte_t pte;
-       int psize, ssize;
+       int psize, ssize, pix;
 
        if (lock_tlbie)
                spin_lock_irqsave(&pSeries_lpar_tlbie_lock, flags);
@@ -599,12 +599,7 @@ static void pSeries_lpar_flush_hash_range(unsigned long 
number, int local)
                vpn = batch->vpn[i];
                pte = batch->pte[i];
                pte_iterate_hashed_subpages(pte, psize, vpn, index, shift) {
-                       hash = hpt_hash(vpn, shift, ssize);
-                       hidx = __rpte_to_hidx(pte, index);
-                       if (hidx & _PTEIDX_SECONDARY)
-                               hash = ~hash;
-                       slot = (hash & htab_hash_mask) * HPTES_PER_GROUP;
-                       slot += hidx & _PTEIDX_GROUP_IX;
+                       slot = pSeries_lpar_hpte_find(vpn, psize, ssize);
                        if (!firmware_has_feature(FW_FEATURE_BULK_REMOVE)) {
                                /*
                                 * lpar doesn't use the passed actual page size
-- 
2.13.3

Reply via email to