pgalloc_64.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #ifndef _SPARC64_PGALLOC_H
  2. #define _SPARC64_PGALLOC_H
  3. #include <linux/kernel.h>
  4. #include <linux/sched.h>
  5. #include <linux/mm.h>
  6. #include <linux/slab.h>
  7. #include <asm/spitfire.h>
  8. #include <asm/cpudata.h>
  9. #include <asm/cacheflush.h>
  10. #include <asm/page.h>
  11. /* Page table allocation/freeing. */
  12. extern struct kmem_cache *pgtable_cache;
  13. static inline void __pgd_populate(pgd_t *pgd, pud_t *pud)
  14. {
  15. pgd_set(pgd, pud);
  16. }
  17. #define pgd_populate(MM, PGD, PUD) __pgd_populate(PGD, PUD)
  18. static inline pgd_t *pgd_alloc(struct mm_struct *mm)
  19. {
  20. return kmem_cache_alloc(pgtable_cache, GFP_KERNEL);
  21. }
  22. static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
  23. {
  24. kmem_cache_free(pgtable_cache, pgd);
  25. }
  26. static inline void __pud_populate(pud_t *pud, pmd_t *pmd)
  27. {
  28. pud_set(pud, pmd);
  29. }
  30. #define pud_populate(MM, PUD, PMD) __pud_populate(PUD, PMD)
  31. static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
  32. {
  33. return kmem_cache_alloc(pgtable_cache, GFP_KERNEL);
  34. }
  35. static inline void pud_free(struct mm_struct *mm, pud_t *pud)
  36. {
  37. kmem_cache_free(pgtable_cache, pud);
  38. }
  39. static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
  40. {
  41. return kmem_cache_alloc(pgtable_cache, GFP_KERNEL);
  42. }
  43. static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
  44. {
  45. kmem_cache_free(pgtable_cache, pmd);
  46. }
  47. pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
  48. unsigned long address);
  49. pgtable_t pte_alloc_one(struct mm_struct *mm,
  50. unsigned long address);
  51. void pte_free_kernel(struct mm_struct *mm, pte_t *pte);
  52. void pte_free(struct mm_struct *mm, pgtable_t ptepage);
  53. #define pmd_populate_kernel(MM, PMD, PTE) pmd_set(MM, PMD, PTE)
  54. #define pmd_populate(MM, PMD, PTE) pmd_set(MM, PMD, PTE)
  55. #define pmd_pgtable(PMD) ((pte_t *)__pmd_page(PMD))
  56. #define check_pgt_cache() do { } while (0)
  57. void pgtable_free(void *table, bool is_page);
  58. #ifdef CONFIG_SMP
  59. struct mmu_gather;
  60. void tlb_remove_table(struct mmu_gather *, void *);
  61. static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, bool is_page)
  62. {
  63. unsigned long pgf = (unsigned long)table;
  64. if (is_page)
  65. pgf |= 0x1UL;
  66. tlb_remove_table(tlb, (void *)pgf);
  67. }
  68. static inline void __tlb_remove_table(void *_table)
  69. {
  70. void *table = (void *)((unsigned long)_table & ~0x1UL);
  71. bool is_page = false;
  72. if ((unsigned long)_table & 0x1UL)
  73. is_page = true;
  74. pgtable_free(table, is_page);
  75. }
  76. #else /* CONFIG_SMP */
  77. static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, bool is_page)
  78. {
  79. pgtable_free(table, is_page);
  80. }
  81. #endif /* !CONFIG_SMP */
  82. static inline void __pte_free_tlb(struct mmu_gather *tlb, pte_t *pte,
  83. unsigned long address)
  84. {
  85. pgtable_free_tlb(tlb, pte, true);
  86. }
  87. #define __pmd_free_tlb(tlb, pmd, addr) \
  88. pgtable_free_tlb(tlb, pmd, false)
  89. #define __pud_free_tlb(tlb, pud, addr) \
  90. pgtable_free_tlb(tlb, pud, false)
  91. #endif /* _SPARC64_PGALLOC_H */