aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64
diff options
context:
space:
mode:
authorzhichang.yuan <zhichang.yuan@linaro.org>2014-12-09 02:26:47 -0500
committerCatalin Marinas <catalin.marinas@arm.com>2015-01-28 07:07:28 -0500
commit523d6e9fae9333a0e2a7baf4d11c8bcca544790e (patch)
tree3c0d9fc243f9e00ce49985e078a8c641029f0833 /arch/arm64
parent62fa5e20bd73385253d2b8d3a51f80d1e6d2e1c6 (diff)
arm64:mm: free the useless initial page table
For 64K page system, after mapping a PMD section, the corresponding initial page table is not needed any more. That page can be freed. Signed-off-by: Zhichang Yuan <zhichang.yuan@linaro.org> [catalin.marinas@arm.com: added BUG_ON() to catch late memblock freeing] Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch/arm64')
-rw-r--r--arch/arm64/include/asm/pgtable.h3
-rw-r--r--arch/arm64/mm/mmu.c15
2 files changed, 15 insertions, 3 deletions
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 59079248529d..67f6ede39474 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -342,9 +342,12 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
342 342
343#ifdef CONFIG_ARM64_64K_PAGES 343#ifdef CONFIG_ARM64_64K_PAGES
344#define pud_sect(pud) (0) 344#define pud_sect(pud) (0)
345#define pud_table(pud) (1)
345#else 346#else
346#define pud_sect(pud) ((pud_val(pud) & PUD_TYPE_MASK) == \ 347#define pud_sect(pud) ((pud_val(pud) & PUD_TYPE_MASK) == \
347 PUD_TYPE_SECT) 348 PUD_TYPE_SECT)
349#define pud_table(pud) ((pud_val(pud) & PUD_TYPE_MASK) == \
350 PUD_TYPE_TABLE)
348#endif 351#endif
349 352
350static inline void set_pmd(pmd_t *pmdp, pmd_t pmd) 353static inline void set_pmd(pmd_t *pmdp, pmd_t pmd)
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 155cbb0a74b6..eb293febfb56 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -153,8 +153,14 @@ static void alloc_init_pmd(struct mm_struct *mm, pud_t *pud,
153 * Check for previous table entries created during 153 * Check for previous table entries created during
154 * boot (__create_page_tables) and flush them. 154 * boot (__create_page_tables) and flush them.
155 */ 155 */
156 if (!pmd_none(old_pmd)) 156 if (!pmd_none(old_pmd)) {
157 flush_tlb_all(); 157 flush_tlb_all();
158 if (pmd_table(old_pmd)) {
159 phys_addr_t table = __pa(pte_offset_map(&old_pmd, 0));
160 BUG_ON(alloc != early_alloc);
161 memblock_free(table, PAGE_SIZE);
162 }
163 }
158 } else { 164 } else {
159 alloc_init_pte(pmd, addr, next, __phys_to_pfn(phys), 165 alloc_init_pte(pmd, addr, next, __phys_to_pfn(phys),
160 prot, alloc); 166 prot, alloc);
@@ -209,9 +215,12 @@ static void alloc_init_pud(struct mm_struct *mm, pgd_t *pgd,
209 * Look up the old pmd table and free it. 215 * Look up the old pmd table and free it.
210 */ 216 */
211 if (!pud_none(old_pud)) { 217 if (!pud_none(old_pud)) {
212 phys_addr_t table = __pa(pmd_offset(&old_pud, 0));
213 memblock_free(table, PAGE_SIZE);
214 flush_tlb_all(); 218 flush_tlb_all();
219 if (pud_table(old_pud)) {
220 phys_addr_t table = __pa(pmd_offset(&old_pud, 0));
221 BUG_ON(alloc != early_alloc);
222 memblock_free(table, PAGE_SIZE);
223 }
215 } 224 }
216 } else { 225 } else {
217 alloc_init_pmd(mm, pud, addr, next, phys, prot, alloc); 226 alloc_init_pmd(mm, pud, addr, next, phys, prot, alloc);