]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - arch/arm/mm/fault-armv.c
ARM: 6464/2: fix spinlock recursion in adjust_pte()
[karo-tx-linux.git] / arch / arm / mm / fault-armv.c
index 9b906dec1ca1abc0ec308472dc39a7684c6c3b01..56036ff04deb5b7d329e10f47ed246ef1dfb03db 100644 (file)
@@ -65,6 +65,30 @@ static int do_adjust_pte(struct vm_area_struct *vma, unsigned long address,
        return ret;
 }
 
+#if USE_SPLIT_PTLOCKS
+/*
+ * If we are using split PTE locks, then we need to take the page
+ * lock here.  Otherwise we are using shared mm->page_table_lock
+ * which is already locked, thus cannot take it.
+ */
+static inline void do_pte_lock(spinlock_t *ptl)
+{
+       /*
+        * Use nested version here to indicate that we are already
+        * holding one similar spinlock.
+        */
+       spin_lock_nested(ptl, SINGLE_DEPTH_NESTING);
+}
+
+static inline void do_pte_unlock(spinlock_t *ptl)
+{
+       spin_unlock(ptl);
+}
+#else /* !USE_SPLIT_PTLOCKS */
+static inline void do_pte_lock(spinlock_t *ptl) {}
+static inline void do_pte_unlock(spinlock_t *ptl) {}
+#endif /* USE_SPLIT_PTLOCKS */
+
 static int adjust_pte(struct vm_area_struct *vma, unsigned long address,
        unsigned long pfn)
 {
@@ -89,11 +113,11 @@ static int adjust_pte(struct vm_area_struct *vma, unsigned long address,
         */
        ptl = pte_lockptr(vma->vm_mm, pmd);
        pte = pte_offset_map_nested(pmd, address);
-       spin_lock(ptl);
+       do_pte_lock(ptl);
 
        ret = do_adjust_pte(vma, address, pfn, pte);
 
-       spin_unlock(ptl);
+       do_pte_unlock(ptl);
        pte_unmap_nested(pte);
 
        return ret;