]> git.karo-electronics.de Git - linux-beck.git/commitdiff
powerpc/mm/radix: Use different pte update sequence for different POWER9 revs
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Wed, 24 Aug 2016 09:33:38 +0000 (15:03 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 13 Sep 2016 07:37:10 +0000 (17:37 +1000)
POWER9 DD1 requires pte to be marked invalid (V=0) before updating
it with the new value. This makes this distinction for the different
revisions.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Acked-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/book3s/32/pgtable.h
arch/powerpc/include/asm/book3s/64/pgtable.h
arch/powerpc/include/asm/book3s/64/radix.h
arch/powerpc/include/asm/nohash/32/pgtable.h
arch/powerpc/include/asm/nohash/64/pgtable.h
arch/powerpc/mm/pgtable-book3s64.c
arch/powerpc/mm/pgtable.c

index 38b33dcfcc9d2379529b3e10289a24f65aeed95b..6b8b2d57fdc8c11851cf8f087898c4c0d24c8e91 100644 (file)
@@ -223,7 +223,8 @@ static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
 }
 
 
-static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry)
+static inline void __ptep_set_access_flags(struct mm_struct *mm,
+                                          pte_t *ptep, pte_t entry)
 {
        unsigned long set = pte_val(entry) &
                (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | _PAGE_EXEC);
index 263bf39ced406e9b8a64f5c416924783fc36b143..8ec8be9495ba73757c801eb8ebfb6eb94b72808e 100644 (file)
@@ -565,10 +565,11 @@ static inline bool check_pte_access(unsigned long access, unsigned long ptev)
  * Generic functions with hash/radix callbacks
  */
 
-static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry)
+static inline void __ptep_set_access_flags(struct mm_struct *mm,
+                                          pte_t *ptep, pte_t entry)
 {
        if (radix_enabled())
-               return radix__ptep_set_access_flags(ptep, entry);
+               return radix__ptep_set_access_flags(mm, ptep, entry);
        return hash__ptep_set_access_flags(ptep, entry);
 }
 
index a2fe8fbfbd3d8066e6ca6a3c81f4a78d88d53329..2a46dea8e1b18c46299c9cc9f3eef4ed7d4ef35b 100644 (file)
 #include <asm/book3s/64/radix-4k.h>
 #endif
 
+#ifndef __ASSEMBLY__
+#include <asm/book3s/64/tlbflush-radix.h>
+#include <asm/cpu_has_feature.h>
+#endif
+
 /* An empty PTE can still have a R or C writeback */
 #define RADIX_PTE_NONE_MASK            (_PAGE_DIRTY | _PAGE_ACCESSED)
 
 #define RADIX_PUD_TABLE_SIZE   (sizeof(pud_t) << RADIX_PUD_INDEX_SIZE)
 #define RADIX_PGD_TABLE_SIZE   (sizeof(pgd_t) << RADIX_PGD_INDEX_SIZE)
 
-static inline unsigned long radix__pte_update(struct mm_struct *mm,
-                                       unsigned long addr,
-                                       pte_t *ptep, unsigned long clr,
-                                       unsigned long set,
-                                       int huge)
+static inline unsigned long __radix_pte_update(pte_t *ptep, unsigned long clr,
+                                              unsigned long set)
 {
        pte_t pte;
        unsigned long old_pte, new_pte;
@@ -121,9 +123,39 @@ static inline unsigned long radix__pte_update(struct mm_struct *mm,
 
        } while (!pte_xchg(ptep, __pte(old_pte), __pte(new_pte)));
 
-       /* We already do a sync in cmpxchg, is ptesync needed ?*/
+       return old_pte;
+}
+
+
+static inline unsigned long radix__pte_update(struct mm_struct *mm,
+                                       unsigned long addr,
+                                       pte_t *ptep, unsigned long clr,
+                                       unsigned long set,
+                                       int huge)
+{
+       unsigned long old_pte;
+
+       if (cpu_has_feature(CPU_FTR_POWER9_DD1)) {
+
+               unsigned long new_pte;
+
+               old_pte = __radix_pte_update(ptep, ~0, 0);
+               asm volatile("ptesync" : : : "memory");
+               /*
+                * new value of pte
+                */
+               new_pte = (old_pte | set) & ~clr;
+
+               /*
+                * For now let's do heavy pid flush
+                * radix__flush_tlb_page_psize(mm, addr, mmu_virtual_psize);
+                */
+               radix__flush_tlb_mm(mm);
+
+               __radix_pte_update(ptep, 0, new_pte);
+       } else
+               old_pte = __radix_pte_update(ptep, clr, set);
        asm volatile("ptesync" : : : "memory");
-       /* huge pages use the old page table lock */
        if (!huge)
                assert_pte_locked(mm, addr);
 
@@ -134,20 +166,33 @@ static inline unsigned long radix__pte_update(struct mm_struct *mm,
  * Set the dirty and/or accessed bits atomically in a linux PTE, this
  * function doesn't need to invalidate tlb.
  */
-static inline void radix__ptep_set_access_flags(pte_t *ptep, pte_t entry)
+static inline void radix__ptep_set_access_flags(struct mm_struct *mm,
+                                               pte_t *ptep, pte_t entry)
 {
-       pte_t pte;
-       unsigned long old_pte, new_pte;
+
        unsigned long set = pte_val(entry) & (_PAGE_DIRTY | _PAGE_ACCESSED |
                                              _PAGE_RW | _PAGE_EXEC);
-       do {
-               pte = READ_ONCE(*ptep);
-               old_pte = pte_val(pte);
+
+       if (cpu_has_feature(CPU_FTR_POWER9_DD1)) {
+
+               unsigned long old_pte, new_pte;
+
+               old_pte = __radix_pte_update(ptep, ~0, 0);
+               asm volatile("ptesync" : : : "memory");
+               /*
+                * new value of pte
+                */
                new_pte = old_pte | set;
 
-       } while (!pte_xchg(ptep, __pte(old_pte), __pte(new_pte)));
+               /*
+                * For now let's do heavy pid flush
+                * radix__flush_tlb_page_psize(mm, addr, mmu_virtual_psize);
+                */
+               radix__flush_tlb_mm(mm);
 
-       /* We already do a sync in cmpxchg, is ptesync needed ?*/
+               __radix_pte_update(ptep, 0, new_pte);
+       } else
+               __radix_pte_update(ptep, 0, set);
        asm volatile("ptesync" : : : "memory");
 }
 
index 78084759751412c3a28e87ed2982899b19595037..c219ef7be53b7f94a616805ce3b39075b8017d66 100644 (file)
@@ -267,7 +267,8 @@ static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
 }
 
 
-static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry)
+static inline void __ptep_set_access_flags(struct mm_struct *mm,
+                                          pte_t *ptep, pte_t entry)
 {
        unsigned long set = pte_val(entry) &
                (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | _PAGE_EXEC);
index d4d808cf905ee25554e49dcf2e7e3f4ed73c4fd7..653a1838469d333f6418a662ea452dc5aa75e623 100644 (file)
@@ -300,7 +300,8 @@ static inline void pte_clear(struct mm_struct *mm, unsigned long addr,
 /* Set the dirty and/or accessed bits atomically in a linux PTE, this
  * function doesn't need to flush the hash entry
  */
-static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry)
+static inline void __ptep_set_access_flags(struct mm_struct *mm,
+                                          pte_t *ptep, pte_t entry)
 {
        unsigned long bits = pte_val(entry) &
                (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | _PAGE_EXEC);
index 34079302cc17488e151c96c121247d2bfb0f1a1f..7328886bca4c32c1c11d8dcbdc70800e1e291191 100644 (file)
@@ -35,7 +35,7 @@ int pmdp_set_access_flags(struct vm_area_struct *vma, unsigned long address,
 #endif
        changed = !pmd_same(*(pmdp), entry);
        if (changed) {
-               __ptep_set_access_flags(pmdp_ptep(pmdp), pmd_pte(entry));
+               __ptep_set_access_flags(vma->vm_mm, pmdp_ptep(pmdp), pmd_pte(entry));
                flush_pmd_tlb_range(vma, address, address + HPAGE_PMD_SIZE);
        }
        return changed;
index 0b6fb244d0a16a4c4e40f7e3f8d15aad83223a3f..911fdfb63ec1783a89a6400c54fc97c21d6b1c11 100644 (file)
@@ -224,7 +224,7 @@ int ptep_set_access_flags(struct vm_area_struct *vma, unsigned long address,
        if (changed) {
                if (!is_vm_hugetlb_page(vma))
                        assert_pte_locked(vma->vm_mm, address);
-               __ptep_set_access_flags(ptep, entry);
+               __ptep_set_access_flags(vma->vm_mm, ptep, entry);
                flush_tlb_page(vma, address);
        }
        return changed;