Paul Mackerras | 047ea78 | 2005-11-19 20:17:32 +1100 | [diff] [blame] | 1 | #ifndef _ASM_POWERPC_PGALLOC_H |
| 2 | #define _ASM_POWERPC_PGALLOC_H |
Arnd Bergmann | 88ced03 | 2005-12-16 22:43:46 +0100 | [diff] [blame] | 3 | #ifdef __KERNEL__ |
Paul Mackerras | 047ea78 | 2005-11-19 20:17:32 +1100 | [diff] [blame] | 4 | |
Kumar Gala | 0186f47 | 2008-11-19 12:50:04 +0000 | [diff] [blame] | 5 | #include <linux/mm.h> |
| 6 | |
Benjamin Herrenschmidt | c7cc58a1 | 2009-07-23 23:15:28 +0000 | [diff] [blame] | 7 | #ifdef CONFIG_PPC_BOOK3E |
| 8 | extern void tlb_flush_pgtable(struct mmu_gather *tlb, unsigned long address); |
| 9 | #else /* CONFIG_PPC_BOOK3E */ |
| 10 | static inline void tlb_flush_pgtable(struct mmu_gather *tlb, |
| 11 | unsigned long address) |
| 12 | { |
| 13 | } |
| 14 | #endif /* !CONFIG_PPC_BOOK3E */ |
| 15 | |
Kumar Gala | 0186f47 | 2008-11-19 12:50:04 +0000 | [diff] [blame] | 16 | static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) |
| 17 | { |
| 18 | free_page((unsigned long)pte); |
| 19 | } |
| 20 | |
| 21 | static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage) |
| 22 | { |
| 23 | pgtable_page_dtor(ptepage); |
| 24 | __free_page(ptepage); |
| 25 | } |
| 26 | |
David Gibson | f88df14 | 2007-04-30 16:30:56 +1000 | [diff] [blame] | 27 | #ifdef CONFIG_PPC64 |
| 28 | #include <asm/pgalloc-64.h> |
Paul Mackerras | 047ea78 | 2005-11-19 20:17:32 +1100 | [diff] [blame] | 29 | #else |
David Gibson | f88df14 | 2007-04-30 16:30:56 +1000 | [diff] [blame] | 30 | #include <asm/pgalloc-32.h> |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 31 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
Kumar Gala | 0186f47 | 2008-11-19 12:50:04 +0000 | [diff] [blame] | 33 | #ifdef CONFIG_SMP |
Peter Zijlstra | 2672391 | 2011-05-24 17:12:00 -0700 | [diff] [blame] | 34 | struct mmu_gather; |
| 35 | extern void tlb_remove_table(struct mmu_gather *, void *); |
| 36 | |
| 37 | static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int shift) |
| 38 | { |
| 39 | unsigned long pgf = (unsigned long)table; |
| 40 | BUG_ON(shift > MAX_PGTABLE_INDEX_SIZE); |
| 41 | pgf |= shift; |
| 42 | tlb_remove_table(tlb, (void *)pgf); |
| 43 | } |
| 44 | |
| 45 | static inline void __tlb_remove_table(void *_table) |
| 46 | { |
| 47 | void *table = (void *)((unsigned long)_table & ~MAX_PGTABLE_INDEX_SIZE); |
| 48 | unsigned shift = (unsigned long)_table & MAX_PGTABLE_INDEX_SIZE; |
| 49 | |
| 50 | pgtable_free(table, shift); |
| 51 | } |
Benjamin Herrenschmidt | c7cc58a1 | 2009-07-23 23:15:28 +0000 | [diff] [blame] | 52 | #else /* CONFIG_SMP */ |
David Gibson | a0668cd | 2009-10-28 16:27:18 +0000 | [diff] [blame] | 53 | static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, unsigned shift) |
Benjamin Herrenschmidt | c7cc58a1 | 2009-07-23 23:15:28 +0000 | [diff] [blame] | 54 | { |
David Gibson | a0668cd | 2009-10-28 16:27:18 +0000 | [diff] [blame] | 55 | pgtable_free(table, shift); |
Benjamin Herrenschmidt | c7cc58a1 | 2009-07-23 23:15:28 +0000 | [diff] [blame] | 56 | } |
Benjamin Herrenschmidt | c7cc58a1 | 2009-07-23 23:15:28 +0000 | [diff] [blame] | 57 | #endif /* !CONFIG_SMP */ |
Kumar Gala | 0186f47 | 2008-11-19 12:50:04 +0000 | [diff] [blame] | 58 | |
Benjamin Herrenschmidt | c7cc58a1 | 2009-07-23 23:15:28 +0000 | [diff] [blame] | 59 | static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *ptepage, |
| 60 | unsigned long address) |
| 61 | { |
Benjamin Herrenschmidt | c7cc58a1 | 2009-07-23 23:15:28 +0000 | [diff] [blame] | 62 | tlb_flush_pgtable(tlb, address); |
| 63 | pgtable_page_dtor(ptepage); |
David Gibson | a0668cd | 2009-10-28 16:27:18 +0000 | [diff] [blame] | 64 | pgtable_free_tlb(tlb, page_address(ptepage), 0); |
Benjamin Herrenschmidt | c7cc58a1 | 2009-07-23 23:15:28 +0000 | [diff] [blame] | 65 | } |
Kumar Gala | 0186f47 | 2008-11-19 12:50:04 +0000 | [diff] [blame] | 66 | |
Arnd Bergmann | 88ced03 | 2005-12-16 22:43:46 +0100 | [diff] [blame] | 67 | #endif /* __KERNEL__ */ |
Paul Mackerras | 047ea78 | 2005-11-19 20:17:32 +1100 | [diff] [blame] | 68 | #endif /* _ASM_POWERPC_PGALLOC_H */ |