[PATCH] ARM: Factor out common pmd_populate functionality

Both pmd_populate variants set two pmd entries before
ensuring that they are flushed from the cache. Separate
this functionality into __pmd_populate().

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

+9 -15
+9 -15
include/asm-arm/pgalloc.h
··· 89 __free_page(pte); 90 } 91 92 /* 93 * Populate the pmdp entry with a pointer to the pte. This pmd is part 94 * of the mm address space. ··· 106 pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep) 107 { 108 unsigned long pte_ptr = (unsigned long)ptep; 109 - unsigned long pmdval; 110 - 111 - BUG_ON(mm != &init_mm); 112 113 /* 114 * The pmd must be loaded with the physical 115 * address of the PTE table 116 */ 117 pte_ptr -= PTRS_PER_PTE * sizeof(void *); 118 - pmdval = __pa(pte_ptr) | _PAGE_KERNEL_TABLE; 119 - pmdp[0] = __pmd(pmdval); 120 - pmdp[1] = __pmd(pmdval + 256 * sizeof(pte_t)); 121 - flush_pmd_entry(pmdp); 122 } 123 124 static inline void 125 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, struct page *ptep) 126 { 127 - unsigned long pmdval; 128 - 129 - BUG_ON(mm == &init_mm); 130 - 131 - pmdval = page_to_pfn(ptep) << PAGE_SHIFT | _PAGE_USER_TABLE; 132 - pmdp[0] = __pmd(pmdval); 133 - pmdp[1] = __pmd(pmdval + 256 * sizeof(pte_t)); 134 - flush_pmd_entry(pmdp); 135 } 136 137 #endif
··· 89 __free_page(pte); 90 } 91 92 + static inline void __pmd_populate(pmd_t *pmdp, unsigned long pmdval) 93 + { 94 + pmdp[0] = __pmd(pmdval); 95 + pmdp[1] = __pmd(pmdval + 256 * sizeof(pte_t)); 96 + flush_pmd_entry(pmdp); 97 + } 98 + 99 /* 100 * Populate the pmdp entry with a pointer to the pte. This pmd is part 101 * of the mm address space. ··· 99 pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep) 100 { 101 unsigned long pte_ptr = (unsigned long)ptep; 102 103 /* 104 * The pmd must be loaded with the physical 105 * address of the PTE table 106 */ 107 pte_ptr -= PTRS_PER_PTE * sizeof(void *); 108 + __pmd_populate(pmdp, __pa(pte_ptr) | _PAGE_KERNEL_TABLE); 109 } 110 111 static inline void 112 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, struct page *ptep) 113 { 114 + __pmd_populate(pmdp, page_to_pfn(ptep) << PAGE_SHIFT | _PAGE_USER_TABLE); 115 } 116 117 #endif