pgalloc.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #ifdef CONFIG_PPC64
  23. #include <asm/pgalloc-64.h>
  24. #else
  25. #include <asm/pgalloc-32.h>
  26. #endif
  27. #ifdef CONFIG_SMP
  28. struct mmu_gather;
  29. extern void tlb_remove_table(struct mmu_gather *, void *);
  30. static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int shift)
  31. {
  32. unsigned long pgf = (unsigned long)table;
  33. BUG_ON(shift > MAX_PGTABLE_INDEX_SIZE);
  34. pgf |= shift;
  35. tlb_remove_table(tlb, (void *)pgf);
  36. }
  37. static inline void __tlb_remove_table(void *_table)
  38. {
  39. void *table = (void *)((unsigned long)_table & ~MAX_PGTABLE_INDEX_SIZE);
  40. unsigned shift = (unsigned long)_table & MAX_PGTABLE_INDEX_SIZE;
  41. pgtable_free(table, shift);
  42. }
  43. #else /* CONFIG_SMP */
  44. static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, unsigned shift)
  45. {
  46. pgtable_free(table, shift);
  47. }
  48. #endif /* !CONFIG_SMP */
  49. static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *ptepage,
  50. unsigned long address)
  51. {
  52. tlb_flush_pgtable(tlb, address);
  53. pgtable_page_dtor(ptepage);
  54. pgtable_free_tlb(tlb, page_address(ptepage), 0);
  55. }
  56. #endif /* __KERNEL__ */
  57. #endif /* _ASM_POWERPC_PGALLOC_H */