pgalloc.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef _ASM_POWERPC_PGALLOC_H
  2. #define _ASM_POWERPC_PGALLOC_H
  3. #ifdef __KERNEL__
  4. #include <linux/mm.h>
  5. #ifdef CONFIG_PPC_BOOK3E
  6. extern void tlb_flush_pgtable(struct mmu_gather *tlb, unsigned long address);
  7. #else /* CONFIG_PPC_BOOK3E */
  8. static inline void tlb_flush_pgtable(struct mmu_gather *tlb,
  9. unsigned long address)
  10. {
  11. }
  12. #endif /* !CONFIG_PPC_BOOK3E */
  13. static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
  14. {
  15. free_page((unsigned long)pte);
  16. }
  17. static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage)
  18. {
  19. pgtable_page_dtor(ptepage);
  20. __free_page(ptepage);
  21. }
  22. typedef struct pgtable_free {
  23. unsigned long val;
  24. } pgtable_free_t;
  25. /* This needs to be big enough to allow for MMU_PAGE_COUNT + 2 to be stored
  26. * and small enough to fit in the low bits of any naturally aligned page
  27. * table cache entry. Arbitrarily set to 0x1f, that should give us some
  28. * room to grow
  29. */
  30. #define PGF_CACHENUM_MASK 0x1f
  31. static inline pgtable_free_t pgtable_free_cache(void *p, int cachenum,
  32. unsigned long mask)
  33. {
  34. BUG_ON(cachenum > PGF_CACHENUM_MASK);
  35. return (pgtable_free_t){.val = ((unsigned long) p & ~mask) | cachenum};
  36. }
  37. #ifdef CONFIG_PPC64
  38. #include <asm/pgalloc-64.h>
  39. #else
  40. #include <asm/pgalloc-32.h>
  41. #endif
  42. #ifdef CONFIG_SMP
  43. extern void pgtable_free_tlb(struct mmu_gather *tlb, pgtable_free_t pgf);
  44. extern void pte_free_finish(void);
  45. #else /* CONFIG_SMP */
  46. static inline void pgtable_free_tlb(struct mmu_gather *tlb, pgtable_free_t pgf)
  47. {
  48. pgtable_free(pgf);
  49. }
  50. static inline void pte_free_finish(void) { }
  51. #endif /* !CONFIG_SMP */
  52. static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *ptepage,
  53. unsigned long address)
  54. {
  55. pgtable_free_t pgf = pgtable_free_cache(page_address(ptepage),
  56. PTE_NONCACHE_NUM,
  57. PTE_TABLE_SIZE-1);
  58. tlb_flush_pgtable(tlb, address);
  59. pgtable_page_dtor(ptepage);
  60. pgtable_free_tlb(tlb, pgf);
  61. }
  62. #endif /* __KERNEL__ */
  63. #endif /* _ASM_POWERPC_PGALLOC_H */