8
8
#ifndef _XTENSA_PGALLOC_H
9
9
#define _XTENSA_PGALLOC_H
10
10
11
+ #ifdef CONFIG_MMU
11
12
#include <linux/highmem.h>
12
13
#include <linux/slab.h>
13
14
15
+ #define __HAVE_ARCH_PTE_ALLOC_ONE_KERNEL
16
+ #define __HAVE_ARCH_PTE_ALLOC_ONE
17
+ #include <asm-generic/pgalloc.h>
18
+
14
19
/*
15
20
* Allocating and freeing a pmd is trivial: the 1-entry pmd is
16
21
* inside the pgd, so has no extra memory associated with it.
@@ -33,45 +38,37 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
33
38
free_page ((unsigned long )pgd );
34
39
}
35
40
41
+ static inline void ptes_clear (pte_t * ptep )
42
+ {
43
+ int i ;
44
+
45
+ for (i = 0 ; i < PTRS_PER_PTE ; i ++ )
46
+ pte_clear (NULL , 0 , ptep + i );
47
+ }
48
+
36
49
static inline pte_t * pte_alloc_one_kernel (struct mm_struct * mm )
37
50
{
38
51
pte_t * ptep ;
39
- int i ;
40
52
41
- ptep = (pte_t * )__get_free_page ( GFP_KERNEL );
53
+ ptep = (pte_t * )__pte_alloc_one_kernel ( mm );
42
54
if (!ptep )
43
55
return NULL ;
44
- for (i = 0 ; i < 1024 ; i ++ )
45
- pte_clear (NULL , 0 , ptep + i );
56
+ ptes_clear (ptep );
46
57
return ptep ;
47
58
}
48
59
49
60
static inline pgtable_t pte_alloc_one (struct mm_struct * mm )
50
61
{
51
- pte_t * pte ;
52
62
struct page * page ;
53
63
54
- pte = pte_alloc_one_kernel (mm );
55
- if (!pte )
56
- return NULL ;
57
- page = virt_to_page (pte );
58
- if (!pgtable_pte_page_ctor (page )) {
59
- __free_page (page );
64
+ page = __pte_alloc_one (mm , GFP_PGTABLE_USER );
65
+ if (!page )
60
66
return NULL ;
61
- }
67
+ ptes_clear ( page_address ( page ));
62
68
return page ;
63
69
}
64
70
65
- static inline void pte_free_kernel (struct mm_struct * mm , pte_t * pte )
66
- {
67
- free_page ((unsigned long )pte );
68
- }
69
-
70
- static inline void pte_free (struct mm_struct * mm , pgtable_t pte )
71
- {
72
- pgtable_pte_page_dtor (pte );
73
- __free_page (pte );
74
- }
75
71
#define pmd_pgtable (pmd ) pmd_page(pmd)
72
+ #endif /* CONFIG_MMU */
76
73
77
74
#endif /* _XTENSA_PGALLOC_H */
0 commit comments