blob: abe8532bd14e4dfc27693cfadce3d49a78380881 [file] [log] [blame]
Paul Mackerras047ea782005-11-19 20:17:32 +11001#ifndef _ASM_POWERPC_PGALLOC_H
2#define _ASM_POWERPC_PGALLOC_H
Arnd Bergmann88ced032005-12-16 22:43:46 +01003#ifdef __KERNEL__
Paul Mackerras047ea782005-11-19 20:17:32 +11004
Kumar Gala0186f472008-11-19 12:50:04 +00005#include <linux/mm.h>
6
Benjamin Herrenschmidtc7cc58a2009-07-23 23:15:28 +00007#ifdef CONFIG_PPC_BOOK3E
8extern void tlb_flush_pgtable(struct mmu_gather *tlb, unsigned long address);
9#else /* CONFIG_PPC_BOOK3E */
10static inline void tlb_flush_pgtable(struct mmu_gather *tlb,
11 unsigned long address)
12{
13}
14#endif /* !CONFIG_PPC_BOOK3E */
15
Kumar Gala0186f472008-11-19 12:50:04 +000016static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
17{
18 free_page((unsigned long)pte);
19}
20
21static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage)
22{
23 pgtable_page_dtor(ptepage);
24 __free_page(ptepage);
25}
26
David Gibsonf88df142007-04-30 16:30:56 +100027#ifdef CONFIG_PPC64
28#include <asm/pgalloc-64.h>
Paul Mackerras047ea782005-11-19 20:17:32 +110029#else
David Gibsonf88df142007-04-30 16:30:56 +100030#include <asm/pgalloc-32.h>
Benjamin Herrenschmidt3c726f82005-11-07 11:06:55 +110031#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
Kumar Gala0186f472008-11-19 12:50:04 +000033#ifdef CONFIG_SMP
David Gibsona0668cd2009-10-28 16:27:18 +000034extern void pgtable_free_tlb(struct mmu_gather *tlb, void *table, unsigned shift);
Benjamin Herrenschmidtc7cc58a2009-07-23 23:15:28 +000035extern void pte_free_finish(void);
36#else /* CONFIG_SMP */
David Gibsona0668cd2009-10-28 16:27:18 +000037static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, unsigned shift)
Benjamin Herrenschmidtc7cc58a2009-07-23 23:15:28 +000038{
David Gibsona0668cd2009-10-28 16:27:18 +000039 pgtable_free(table, shift);
Benjamin Herrenschmidtc7cc58a2009-07-23 23:15:28 +000040}
41static inline void pte_free_finish(void) { }
42#endif /* !CONFIG_SMP */
Kumar Gala0186f472008-11-19 12:50:04 +000043
Benjamin Herrenschmidtc7cc58a2009-07-23 23:15:28 +000044static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *ptepage,
45 unsigned long address)
46{
Benjamin Herrenschmidtc7cc58a2009-07-23 23:15:28 +000047 tlb_flush_pgtable(tlb, address);
48 pgtable_page_dtor(ptepage);
David Gibsona0668cd2009-10-28 16:27:18 +000049 pgtable_free_tlb(tlb, page_address(ptepage), 0);
Benjamin Herrenschmidtc7cc58a2009-07-23 23:15:28 +000050}
Kumar Gala0186f472008-11-19 12:50:04 +000051
Arnd Bergmann88ced032005-12-16 22:43:46 +010052#endif /* __KERNEL__ */
Paul Mackerras047ea782005-11-19 20:17:32 +110053#endif /* _ASM_POWERPC_PGALLOC_H */