]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - arch/score/include/asm/pgalloc.h
Merge branch 'for-4.8/core' of git://git.kernel.dk/linux-block
[karo-tx-linux.git] / arch / score / include / asm / pgalloc.h
1 #ifndef _ASM_SCORE_PGALLOC_H
2 #define _ASM_SCORE_PGALLOC_H
3
4 #include <linux/mm.h>
5 #include <linux/highmem.h>
6 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
7         pte_t *pte)
8 {
9         set_pmd(pmd, __pmd((unsigned long)pte));
10 }
11
12 static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
13         pgtable_t pte)
14 {
15         set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
16 }
17
18 #define pmd_pgtable(pmd)        pmd_page(pmd)
19
20 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
21 {
22         pgd_t *ret, *init;
23
24         ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_ORDER);
25         if (ret) {
26                 init = pgd_offset(&init_mm, 0UL);
27                 pgd_init((unsigned long)ret);
28                 memcpy(ret + USER_PTRS_PER_PGD, init + USER_PTRS_PER_PGD,
29                 (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
30         }
31
32         return ret;
33 }
34
35 static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
36 {
37         free_pages((unsigned long)pgd, PGD_ORDER);
38 }
39
40 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
41         unsigned long address)
42 {
43         pte_t *pte;
44
45         pte = (pte_t *) __get_free_pages(GFP_KERNEL|__GFP_ZERO, PTE_ORDER);
46
47         return pte;
48 }
49
50 static inline struct page *pte_alloc_one(struct mm_struct *mm,
51         unsigned long address)
52 {
53         struct page *pte;
54
55         pte = alloc_pages(GFP_KERNEL, PTE_ORDER);
56         if (!pte)
57                 return NULL;
58         clear_highpage(pte);
59         if (!pgtable_page_ctor(pte)) {
60                 __free_page(pte);
61                 return NULL;
62         }
63         return pte;
64 }
65
66 static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
67 {
68         free_pages((unsigned long)pte, PTE_ORDER);
69 }
70
71 static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
72 {
73         pgtable_page_dtor(pte);
74         __free_pages(pte, PTE_ORDER);
75 }
76
77 #define __pte_free_tlb(tlb, pte, buf)                   \
78 do {                                                    \
79         pgtable_page_dtor(pte);                         \
80         tlb_remove_page((tlb), pte);                    \
81 } while (0)
82
83 #define check_pgt_cache()               do {} while (0)
84
85 #endif /* _ASM_SCORE_PGALLOC_H */