1f15cbe6fSPaul Mundt #ifndef __ASM_SH_PGALLOC_H 2f15cbe6fSPaul Mundt #define __ASM_SH_PGALLOC_H 3f15cbe6fSPaul Mundt 4f15cbe6fSPaul Mundt #include <linux/quicklist.h> 5f15cbe6fSPaul Mundt #include <asm/page.h> 6f15cbe6fSPaul Mundt 7f15cbe6fSPaul Mundt #define QUICK_PT 1 /* Other page table pages that are zero on free */ 8f15cbe6fSPaul Mundt 9*5d9b4b19SMatt Fleming #ifdef CONFIG_PGTABLE_LEVELS_3 10*5d9b4b19SMatt Fleming #include <asm/pgalloc_pmd.h> 11*5d9b4b19SMatt Fleming #else 12b73c8063SMatt Fleming #include <asm/pgalloc_nopmd.h> 13*5d9b4b19SMatt Fleming #endif 14b73c8063SMatt Fleming 15f15cbe6fSPaul Mundt static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, 16f15cbe6fSPaul Mundt pte_t *pte) 17f15cbe6fSPaul Mundt { 18f15cbe6fSPaul Mundt set_pmd(pmd, __pmd((unsigned long)pte)); 19f15cbe6fSPaul Mundt } 20f15cbe6fSPaul Mundt 21f15cbe6fSPaul Mundt static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, 22f15cbe6fSPaul Mundt pgtable_t pte) 23f15cbe6fSPaul Mundt { 24f15cbe6fSPaul Mundt set_pmd(pmd, __pmd((unsigned long)page_address(pte))); 25f15cbe6fSPaul Mundt } 26f15cbe6fSPaul Mundt #define pmd_pgtable(pmd) pmd_page(pmd) 27f15cbe6fSPaul Mundt 28f15cbe6fSPaul Mundt /* 29f15cbe6fSPaul Mundt * Allocate and free page tables. 30f15cbe6fSPaul Mundt */ 31f15cbe6fSPaul Mundt static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 32f15cbe6fSPaul Mundt unsigned long address) 33f15cbe6fSPaul Mundt { 34f15cbe6fSPaul Mundt return quicklist_alloc(QUICK_PT, GFP_KERNEL | __GFP_REPEAT, NULL); 35f15cbe6fSPaul Mundt } 36f15cbe6fSPaul Mundt 37f15cbe6fSPaul Mundt static inline pgtable_t pte_alloc_one(struct mm_struct *mm, 38f15cbe6fSPaul Mundt unsigned long address) 39f15cbe6fSPaul Mundt { 40f15cbe6fSPaul Mundt struct page *page; 41f15cbe6fSPaul Mundt void *pg; 42f15cbe6fSPaul Mundt 43f15cbe6fSPaul Mundt pg = quicklist_alloc(QUICK_PT, GFP_KERNEL | __GFP_REPEAT, NULL); 44f15cbe6fSPaul Mundt if (!pg) 45f15cbe6fSPaul Mundt return NULL; 46f15cbe6fSPaul Mundt page = virt_to_page(pg); 47f15cbe6fSPaul Mundt pgtable_page_ctor(page); 48f15cbe6fSPaul Mundt return page; 49f15cbe6fSPaul Mundt } 50f15cbe6fSPaul Mundt 51f15cbe6fSPaul Mundt static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) 52f15cbe6fSPaul Mundt { 53f15cbe6fSPaul Mundt quicklist_free(QUICK_PT, NULL, pte); 54f15cbe6fSPaul Mundt } 55f15cbe6fSPaul Mundt 56f15cbe6fSPaul Mundt static inline void pte_free(struct mm_struct *mm, pgtable_t pte) 57f15cbe6fSPaul Mundt { 58f15cbe6fSPaul Mundt pgtable_page_dtor(pte); 59f15cbe6fSPaul Mundt quicklist_free_page(QUICK_PT, NULL, pte); 60f15cbe6fSPaul Mundt } 61f15cbe6fSPaul Mundt 629e1b32caSBenjamin Herrenschmidt #define __pte_free_tlb(tlb,pte,addr) \ 63f15cbe6fSPaul Mundt do { \ 64f15cbe6fSPaul Mundt pgtable_page_dtor(pte); \ 65f15cbe6fSPaul Mundt tlb_remove_page((tlb), (pte)); \ 66f15cbe6fSPaul Mundt } while (0) 67f15cbe6fSPaul Mundt 68f15cbe6fSPaul Mundt static inline void check_pgt_cache(void) 69f15cbe6fSPaul Mundt { 70b73c8063SMatt Fleming __check_pgt_cache(); 71f15cbe6fSPaul Mundt quicklist_trim(QUICK_PT, NULL, 25, 16); 72f15cbe6fSPaul Mundt } 73f15cbe6fSPaul Mundt 74f15cbe6fSPaul Mundt #endif /* __ASM_SH_PGALLOC_H */ 75