blob: bf301ac62f35a0c1da1ed7b9cae0de43c95d0df0 [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 Herrenschmidtc7cc58a12009-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
Peter Zijlstra26723912011-05-24 17:12:00 -070034struct mmu_gather;
35extern void tlb_remove_table(struct mmu_gather *, void *);
36
37static 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
45static 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 Herrenschmidtc7cc58a12009-07-23 23:15:28 +000052#else /* CONFIG_SMP */
David Gibsona0668cd2009-10-28 16:27:18 +000053static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, unsigned shift)
Benjamin Herrenschmidtc7cc58a12009-07-23 23:15:28 +000054{
David Gibsona0668cd2009-10-28 16:27:18 +000055 pgtable_free(table, shift);
Benjamin Herrenschmidtc7cc58a12009-07-23 23:15:28 +000056}
Benjamin Herrenschmidtc7cc58a12009-07-23 23:15:28 +000057#endif /* !CONFIG_SMP */
Kumar Gala0186f472008-11-19 12:50:04 +000058
Benjamin Herrenschmidtc7cc58a12009-07-23 23:15:28 +000059static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *ptepage,
60 unsigned long address)
61{
Benjamin Herrenschmidtc7cc58a12009-07-23 23:15:28 +000062 tlb_flush_pgtable(tlb, address);
63 pgtable_page_dtor(ptepage);
David Gibsona0668cd2009-10-28 16:27:18 +000064 pgtable_free_tlb(tlb, page_address(ptepage), 0);
Benjamin Herrenschmidtc7cc58a12009-07-23 23:15:28 +000065}
Kumar Gala0186f472008-11-19 12:50:04 +000066
Arnd Bergmann88ced032005-12-16 22:43:46 +010067#endif /* __KERNEL__ */
Paul Mackerras047ea782005-11-19 20:17:32 +110068#endif /* _ASM_POWERPC_PGALLOC_H */