2005-11-19 02:17:32 -07:00
|
|
|
#ifndef _ASM_POWERPC_PGALLOC_H
|
|
|
|
#define _ASM_POWERPC_PGALLOC_H
|
2005-12-16 14:43:46 -07:00
|
|
|
#ifdef __KERNEL__
|
2005-11-19 02:17:32 -07:00
|
|
|
|
2008-11-19 05:50:04 -07:00
|
|
|
#include <linux/mm.h>
|
|
|
|
|
2009-07-23 16:15:28 -07:00
|
|
|
#ifdef CONFIG_PPC_BOOK3E
|
|
|
|
extern void tlb_flush_pgtable(struct mmu_gather *tlb, unsigned long address);
|
|
|
|
#else /* CONFIG_PPC_BOOK3E */
|
|
|
|
static inline void tlb_flush_pgtable(struct mmu_gather *tlb,
|
|
|
|
unsigned long address)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif /* !CONFIG_PPC_BOOK3E */
|
|
|
|
|
2008-11-19 05:50:04 -07:00
|
|
|
static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
|
|
|
|
{
|
|
|
|
free_page((unsigned long)pte);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage)
|
|
|
|
{
|
|
|
|
pgtable_page_dtor(ptepage);
|
|
|
|
__free_page(ptepage);
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct pgtable_free {
|
|
|
|
unsigned long val;
|
|
|
|
} pgtable_free_t;
|
|
|
|
|
2009-08-05 20:50:58 -07:00
|
|
|
/* This needs to be big enough to allow for MMU_PAGE_COUNT + 2 to be stored
|
|
|
|
* and small enough to fit in the low bits of any naturally aligned page
|
|
|
|
* table cache entry. Arbitrarily set to 0x1f, that should give us some
|
|
|
|
* room to grow
|
|
|
|
*/
|
|
|
|
#define PGF_CACHENUM_MASK 0x1f
|
2008-11-19 05:50:04 -07:00
|
|
|
|
|
|
|
static inline pgtable_free_t pgtable_free_cache(void *p, int cachenum,
|
|
|
|
unsigned long mask)
|
|
|
|
{
|
|
|
|
BUG_ON(cachenum > PGF_CACHENUM_MASK);
|
|
|
|
|
|
|
|
return (pgtable_free_t){.val = ((unsigned long) p & ~mask) | cachenum};
|
|
|
|
}
|
|
|
|
|
2007-04-29 23:30:56 -07:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
#include <asm/pgalloc-64.h>
|
2005-11-19 02:17:32 -07:00
|
|
|
#else
|
2007-04-29 23:30:56 -07:00
|
|
|
#include <asm/pgalloc-32.h>
|
2005-11-06 17:06:55 -07:00
|
|
|
#endif
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-11-19 05:50:04 -07:00
|
|
|
#ifdef CONFIG_SMP
|
2009-07-23 16:15:28 -07:00
|
|
|
extern void pgtable_free_tlb(struct mmu_gather *tlb, pgtable_free_t pgf);
|
|
|
|
extern void pte_free_finish(void);
|
|
|
|
#else /* CONFIG_SMP */
|
|
|
|
static inline void pgtable_free_tlb(struct mmu_gather *tlb, pgtable_free_t pgf)
|
|
|
|
{
|
|
|
|
pgtable_free(pgf);
|
|
|
|
}
|
|
|
|
static inline void pte_free_finish(void) { }
|
|
|
|
#endif /* !CONFIG_SMP */
|
2008-11-19 05:50:04 -07:00
|
|
|
|
2009-07-23 16:15:28 -07:00
|
|
|
static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *ptepage,
|
|
|
|
unsigned long address)
|
|
|
|
{
|
|
|
|
pgtable_free_t pgf = pgtable_free_cache(page_address(ptepage),
|
|
|
|
PTE_NONCACHE_NUM,
|
|
|
|
PTE_TABLE_SIZE-1);
|
|
|
|
tlb_flush_pgtable(tlb, address);
|
|
|
|
pgtable_page_dtor(ptepage);
|
|
|
|
pgtable_free_tlb(tlb, pgf);
|
|
|
|
}
|
2008-11-19 05:50:04 -07:00
|
|
|
|
2005-12-16 14:43:46 -07:00
|
|
|
#endif /* __KERNEL__ */
|
2005-11-19 02:17:32 -07:00
|
|
|
#endif /* _ASM_POWERPC_PGALLOC_H */
|