powerpc/mm: move slice_mask_for_size() into mmu.h
authorChristophe Leroy <christophe.leroy@c-s.fr>
Thu, 25 Apr 2019 14:29:30 +0000 (14:29 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 2 May 2019 15:20:22 +0000 (01:20 +1000)
Move slice_mask_for_size() into subarch mmu.h

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
[mpe: Retain the BUG_ON()s, rather than converting to VM_BUG_ON()]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/book3s/64/mmu.h
arch/powerpc/include/asm/nohash/32/mmu-8xx.h
arch/powerpc/mm/slice.c

index 230a9dec7677484b1ba58afcc5b55ab8f7ba53fc..a6d5b5ed11709bc8c3831fe7b8fa1d3de6a99b9f 100644 (file)
@@ -203,6 +203,23 @@ static inline struct slice_mask *mm_ctx_slice_mask_16g(mm_context_t *ctx)
 }
 #endif
 
+static inline struct slice_mask *slice_mask_for_size(mm_context_t *ctx, int psize)
+{
+#ifdef CONFIG_PPC_64K_PAGES
+       if (psize == MMU_PAGE_64K)
+               return mm_ctx_slice_mask_64k(&ctx);
+#endif
+#ifdef CONFIG_HUGETLB_PAGE
+       if (psize == MMU_PAGE_16M)
+               return mm_ctx_slice_mask_16m(&ctx);
+       if (psize == MMU_PAGE_16G)
+               return mm_ctx_slice_mask_16g(&ctx);
+#endif
+       BUG_ON(psize != MMU_PAGE_4K);
+
+       return mm_ctx_slice_mask_4k(&ctx);
+}
+
 #ifdef CONFIG_PPC_SUBPAGE_PROT
 static inline struct subpage_prot_table *mm_ctx_subpage_prot(mm_context_t *ctx)
 {
index c503e2f05e6115fb8ecd504e4ca568e08ff49962..114f50d995dc836820dc89cc73679517003cc80c 100644 (file)
 #define LOW_SLICE_ARRAY_SZ     SLICE_ARRAY_SIZE
 #endif
 
+#if defined(CONFIG_PPC_4K_PAGES)
+#define mmu_virtual_psize      MMU_PAGE_4K
+#elif defined(CONFIG_PPC_16K_PAGES)
+#define mmu_virtual_psize      MMU_PAGE_16K
+#define PTE_FRAG_NR            4
+#define PTE_FRAG_SIZE_SHIFT    12
+#define PTE_FRAG_SIZE          (1UL << 12)
+#else
+#error "Unsupported PAGE_SIZE"
+#endif
+
+#define mmu_linear_psize       MMU_PAGE_8M
+
 #ifndef __ASSEMBLY__
+
+#include <linux/mmdebug.h>
+
 struct slice_mask {
        u64 low_slices;
        DECLARE_BITMAP(high_slices, 0);
@@ -255,6 +271,19 @@ static inline struct slice_mask *mm_ctx_slice_mask_8m(mm_context_t *ctx)
        return &ctx->mask_8m;
 }
 #endif
+
+static inline struct slice_mask *slice_mask_for_size(mm_context_t *ctx, int psize)
+{
+#ifdef CONFIG_HUGETLB_PAGE
+       if (psize == MMU_PAGE_512K)
+               return &ctx->mask_512k;
+       if (psize == MMU_PAGE_8M)
+               return &ctx->mask_8m;
+#endif
+       BUG_ON(psize != mmu_virtual_psize);
+
+       return &ctx->mask_base_psize;
+}
 #endif /* CONFIG_PPC_MM_SLICE */
 
 #define PHYS_IMMR_BASE (mfspr(SPRN_IMMR) & 0xfff80000)
@@ -306,17 +335,4 @@ extern s32 patch__itlbmiss_perf, patch__dtlbmiss_perf;
 
 #endif /* !__ASSEMBLY__ */
 
-#if defined(CONFIG_PPC_4K_PAGES)
-#define mmu_virtual_psize      MMU_PAGE_4K
-#elif defined(CONFIG_PPC_16K_PAGES)
-#define mmu_virtual_psize      MMU_PAGE_16K
-#define PTE_FRAG_NR            4
-#define PTE_FRAG_SIZE_SHIFT    12
-#define PTE_FRAG_SIZE          (1UL << 12)
-#else
-#error "Unsupported PAGE_SIZE"
-#endif
-
-#define mmu_linear_psize       MMU_PAGE_8M
-
 #endif /* _ASM_POWERPC_MMU_8XX_H_ */
index 8eb7e8b09c7592e0bfb3c092d2802b4dee320122..31de91b65a646c9ba838a8cd54a4532df6abceb7 100644 (file)
@@ -150,40 +150,6 @@ static void slice_mask_for_free(struct mm_struct *mm, struct slice_mask *ret,
                        __set_bit(i, ret->high_slices);
 }
 
-#ifdef CONFIG_PPC_BOOK3S_64
-static struct slice_mask *slice_mask_for_size(mm_context_t *ctx, int psize)
-{
-#ifdef CONFIG_PPC_64K_PAGES
-       if (psize == MMU_PAGE_64K)
-               return mm_ctx_slice_mask_64k(&ctx);
-#endif
-       if (psize == MMU_PAGE_4K)
-               return mm_ctx_slice_mask_4k(&ctx);
-#ifdef CONFIG_HUGETLB_PAGE
-       if (psize == MMU_PAGE_16M)
-               return mm_ctx_slice_mask_16m(&ctx);
-       if (psize == MMU_PAGE_16G)
-               return mm_ctx_slice_mask_16g(&ctx);
-#endif
-       BUG();
-}
-#elif defined(CONFIG_PPC_8xx)
-static struct slice_mask *slice_mask_for_size(mm_context_t *ctx, int psize)
-{
-       if (psize == mmu_virtual_psize)
-               return &ctx->mask_base_psize;
-#ifdef CONFIG_HUGETLB_PAGE
-       if (psize == MMU_PAGE_512K)
-               return &ctx->mask_512k;
-       if (psize == MMU_PAGE_8M)
-               return &ctx->mask_8m;
-#endif
-       BUG();
-}
-#else
-#error "Must define the slice masks for page sizes supported by the platform"
-#endif
-
 static bool slice_check_range_fits(struct mm_struct *mm,
                           const struct slice_mask *available,
                           unsigned long start, unsigned long len)