blob: fe9f037ac5fdfd9f3f21f6737851c002d0c28241 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __ASM_SH_PGALLOC_H
2#define __ASM_SH_PGALLOC_H
3
Paul Mundt5f8c9902007-05-08 11:55:21 +09004#include <linux/quicklist.h>
5#include <asm/page.h>
6
Paul Mundt5f8c9902007-05-08 11:55:21 +09007#define QUICK_PT 1 /* Other page table pages that are zero on free */
8
Matt Flemingb73c8062009-11-25 22:00:08 +00009#include <asm/pgalloc_nopmd.h>
10
Stuart Menefy99a596f2006-11-21 15:38:05 +090011static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
12 pte_t *pte)
13{
14 set_pmd(pmd, __pmd((unsigned long)pte));
15}
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
17static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080018 pgtable_t pte)
Linus Torvalds1da177e2005-04-16 15:20:36 -070019{
Stuart Menefy99a596f2006-11-21 15:38:05 +090020 set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
Linus Torvalds1da177e2005-04-16 15:20:36 -070021}
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080022#define pmd_pgtable(pmd) pmd_page(pmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
24/*
25 * Allocate and free page tables.
26 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070027static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
28 unsigned long address)
29{
Paul Mundt1039b9a2007-05-08 12:07:21 +090030 return quicklist_alloc(QUICK_PT, GFP_KERNEL | __GFP_REPEAT, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070031}
32
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080033static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
34 unsigned long address)
Linus Torvalds1da177e2005-04-16 15:20:36 -070035{
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080036 struct page *page;
37 void *pg;
38
39 pg = quicklist_alloc(QUICK_PT, GFP_KERNEL | __GFP_REPEAT, NULL);
40 if (!pg)
41 return NULL;
42 page = virt_to_page(pg);
43 pgtable_page_ctor(page);
44 return page;
Linus Torvalds1da177e2005-04-16 15:20:36 -070045}
46
Benjamin Herrenschmidt5e541972008-02-04 22:29:14 -080047static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
Linus Torvalds1da177e2005-04-16 15:20:36 -070048{
Paul Mundt5f8c9902007-05-08 11:55:21 +090049 quicklist_free(QUICK_PT, NULL, pte);
Linus Torvalds1da177e2005-04-16 15:20:36 -070050}
51
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080052static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
Linus Torvalds1da177e2005-04-16 15:20:36 -070053{
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080054 pgtable_page_dtor(pte);
Paul Mundt5f8c9902007-05-08 11:55:21 +090055 quicklist_free_page(QUICK_PT, NULL, pte);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056}
57
Benjamin Herrenschmidt9e1b32c2009-07-22 15:44:28 +100058#define __pte_free_tlb(tlb,pte,addr) \
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080059do { \
60 pgtable_page_dtor(pte); \
61 tlb_remove_page((tlb), (pte)); \
62} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
Paul Mundt5f8c9902007-05-08 11:55:21 +090064static inline void check_pgt_cache(void)
65{
Matt Flemingb73c8062009-11-25 22:00:08 +000066 __check_pgt_cache();
Paul Mundt5f8c9902007-05-08 11:55:21 +090067 quicklist_trim(QUICK_PT, NULL, 25, 16);
68}
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
Linus Torvalds1da177e2005-04-16 15:20:36 -070070#endif /* __ASM_SH_PGALLOC_H */