0001
0002 #ifndef _ASM_POWERPC_NOHASH_PGALLOC_H
0003 #define _ASM_POWERPC_NOHASH_PGALLOC_H
0004
0005 #include <linux/mm.h>
0006 #include <linux/slab.h>
0007
0008 extern void tlb_remove_table(struct mmu_gather *tlb, void *table);
0009 #ifdef CONFIG_PPC64
0010 extern void tlb_flush_pgtable(struct mmu_gather *tlb, unsigned long address);
0011 #else
0012
0013 static inline void tlb_flush_pgtable(struct mmu_gather *tlb,
0014 unsigned long address)
0015 {
0016
0017 }
0018 #endif
0019
0020 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
0021 {
0022 return kmem_cache_alloc(PGT_CACHE(PGD_INDEX_SIZE),
0023 pgtable_gfp_flags(mm, GFP_KERNEL));
0024 }
0025
0026 static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
0027 {
0028 kmem_cache_free(PGT_CACHE(PGD_INDEX_SIZE), pgd);
0029 }
0030
0031 #ifdef CONFIG_PPC64
0032 #include <asm/nohash/64/pgalloc.h>
0033 #else
0034 #include <asm/nohash/32/pgalloc.h>
0035 #endif
0036
0037 static inline void pgtable_free(void *table, int shift)
0038 {
0039 if (!shift) {
0040 pte_fragment_free((unsigned long *)table, 0);
0041 } else {
0042 BUG_ON(shift > MAX_PGTABLE_INDEX_SIZE);
0043 kmem_cache_free(PGT_CACHE(shift), table);
0044 }
0045 }
0046
0047 #define get_hugepd_cache_index(x) (x)
0048
0049 static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int shift)
0050 {
0051 unsigned long pgf = (unsigned long)table;
0052
0053 BUG_ON(shift > MAX_PGTABLE_INDEX_SIZE);
0054 pgf |= shift;
0055 tlb_remove_table(tlb, (void *)pgf);
0056 }
0057
0058 static inline void __tlb_remove_table(void *_table)
0059 {
0060 void *table = (void *)((unsigned long)_table & ~MAX_PGTABLE_INDEX_SIZE);
0061 unsigned shift = (unsigned long)_table & MAX_PGTABLE_INDEX_SIZE;
0062
0063 pgtable_free(table, shift);
0064 }
0065
0066 static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,
0067 unsigned long address)
0068 {
0069 tlb_flush_pgtable(tlb, address);
0070 pgtable_free_tlb(tlb, table, 0);
0071 }
0072 #endif