ARM: early_pte_alloc()
authorRussell King <rmk+kernel@arm.linux.org.uk>
Thu, 1 Jul 2010 17:33:29 +0000 (18:33 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Tue, 27 Jul 2010 07:47:59 +0000 (08:47 +0100)
Provide a common function for allocating early PTE tables.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/mm/mmu.c

index 3079d0fd9cead20a2c188bd19223101f159fbd09..05dbb956175b06157ee0ef39a719b94bb005b1be 100644 (file)
@@ -492,18 +492,21 @@ static void __init *early_alloc(unsigned long sz)
        return alloc_bootmem_low_pages(sz);
 }
 
        return alloc_bootmem_low_pages(sz);
 }
 
-static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr,
-                                 unsigned long end, unsigned long pfn,
-                                 const struct mem_type *type)
+static pte_t * __init early_pte_alloc(pmd_t *pmd, unsigned long addr, unsigned long prot)
 {
 {
-       pte_t *pte;
-
        if (pmd_none(*pmd)) {
        if (pmd_none(*pmd)) {
-               pte = early_alloc(2 * PTRS_PER_PTE * sizeof(pte_t));
-               __pmd_populate(pmd, __pa(pte) | type->prot_l1);
+               pte_t *pte = early_alloc(2 * PTRS_PER_PTE * sizeof(pte_t));
+               __pmd_populate(pmd, __pa(pte) | prot);
        }
        }
+       BUG_ON(pmd_bad(*pmd));
+       return pte_offset_kernel(pmd, addr);
+}
 
 
-       pte = pte_offset_kernel(pmd, addr);
+static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr,
+                                 unsigned long end, unsigned long pfn,
+                                 const struct mem_type *type)
+{
+       pte_t *pte = early_pte_alloc(pmd, addr, type->prot_l1);
        do {
                set_pte_ext(pte, pfn_pte(pfn, __pgprot(type->prot_pte)), 0);
                pfn++;
        do {
                set_pte_ext(pte, pfn_pte(pfn, __pgprot(type->prot_pte)), 0);
                pfn++;
@@ -949,11 +952,8 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
 static void __init kmap_init(void)
 {
 #ifdef CONFIG_HIGHMEM
 static void __init kmap_init(void)
 {
 #ifdef CONFIG_HIGHMEM
-       pmd_t *pmd = pmd_off_k(PKMAP_BASE);
-       pte_t *pte = early_alloc(2 * PTRS_PER_PTE * sizeof(pte_t));
-       BUG_ON(!pmd_none(*pmd) || !pte);
-       __pmd_populate(pmd, __pa(pte) | _PAGE_KERNEL_TABLE);
-       pkmap_page_table = pte + PTRS_PER_PTE;
+       pkmap_page_table = early_pte_alloc(pmd_off_k(PKMAP_BASE),
+               PKMAP_BASE, _PAGE_KERNEL_TABLE);
 #endif
 }
 
 #endif
 }