sh: Abstract the number of page table levels
authorMatt Fleming <matt@console-pimps.org>
Wed, 25 Nov 2009 22:00:08 +0000 (22:00 +0000)
committerPaul Mundt <lethal@linux-sh.org>
Thu, 17 Dec 2009 05:31:15 +0000 (14:31 +0900)
Keep the dimensions of the page tables in a separate header file in
preparation for allowing a three level page table structure.

Signed-off-by: Matt Fleming <matt@console-pimps.org>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
arch/sh/include/asm/pgalloc.h
arch/sh/include/asm/pgalloc_nopmd.h [new file with mode: 0644]
arch/sh/include/asm/pgtable.h
arch/sh/include/asm/pgtable_nopmd.h [new file with mode: 0644]

index 63ca37b..fe9f037 100644 (file)
@@ -4,9 +4,10 @@
 #include <linux/quicklist.h>
 #include <asm/page.h>
 
-#define QUICK_PGD 0    /* We preserve special mappings over free */
 #define QUICK_PT 1     /* Other page table pages that are zero on free */
 
+#include <asm/pgalloc_nopmd.h>
+
 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
                                       pte_t *pte)
 {
@@ -20,28 +21,9 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
 }
 #define pmd_pgtable(pmd) pmd_page(pmd)
 
-static inline void pgd_ctor(void *x)
-{
-       pgd_t *pgd = x;
-
-       memcpy(pgd + USER_PTRS_PER_PGD,
-              swapper_pg_dir + USER_PTRS_PER_PGD,
-              (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
-}
-
 /*
  * Allocate and free page tables.
  */
-static inline pgd_t *pgd_alloc(struct mm_struct *mm)
-{
-       return quicklist_alloc(QUICK_PGD, GFP_KERNEL | __GFP_REPEAT, pgd_ctor);
-}
-
-static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
-{
-       quicklist_free(QUICK_PGD, NULL, pgd);
-}
-
 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
                                          unsigned long address)
 {
@@ -81,7 +63,7 @@ do {                                                  \
 
 static inline void check_pgt_cache(void)
 {
-       quicklist_trim(QUICK_PGD, NULL, 25, 16);
+       __check_pgt_cache();
        quicklist_trim(QUICK_PT, NULL, 25, 16);
 }
 
diff --git a/arch/sh/include/asm/pgalloc_nopmd.h b/arch/sh/include/asm/pgalloc_nopmd.h
new file mode 100644 (file)
index 0000000..e4b344c
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef __ASM_SH_PGALLOC_NOPMD_H
+#define __ASM_SH_PGALLOC_NOPMD_H
+
+#define QUICK_PGD 0    /* We preserve special mappings over free */
+
+static inline void pgd_ctor(void *x)
+{
+       pgd_t *pgd = x;
+
+       memcpy(pgd + USER_PTRS_PER_PGD,
+              swapper_pg_dir + USER_PTRS_PER_PGD,
+              (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
+}
+
+static inline pgd_t *pgd_alloc(struct mm_struct *mm)
+{
+       return quicklist_alloc(QUICK_PGD, GFP_KERNEL | __GFP_REPEAT, pgd_ctor);
+}
+
+static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
+{
+       quicklist_free(QUICK_PGD, NULL, pgd);
+}
+
+static inline void __check_pgt_cache(void)
+{
+       quicklist_trim(QUICK_PGD, NULL, 25, 16);
+}
+
+#endif /* __ASM_SH_PGALLOC_NOPMD_H */
index ba3046e..9a0f66c 100644 (file)
@@ -12,7 +12,7 @@
 #ifndef __ASM_SH_PGTABLE_H
 #define __ASM_SH_PGTABLE_H
 
-#include <asm-generic/pgtable-nopmd.h>
+#include <asm/pgtable_nopmd.h>
 #include <asm/page.h>
 
 #ifndef __ASSEMBLY__
@@ -51,28 +51,12 @@ static inline unsigned long long neff_sign_extend(unsigned long val)
 #define        NPHYS_SIGN      (1LL << (NPHYS - 1))
 #define        NPHYS_MASK      (-1LL << NPHYS)
 
-/*
- * traditional two-level paging structure
- */
-/* PTE bits */
-#if defined(CONFIG_X2TLB) || defined(CONFIG_SUPERH64)
-# define PTE_MAGNITUDE 3       /* 64-bit PTEs on extended mode SH-X2 TLB */
-#else
-# define PTE_MAGNITUDE 2       /* 32-bit PTEs */
-#endif
-#define PTE_SHIFT      PAGE_SHIFT
-#define PTE_BITS       (PTE_SHIFT - PTE_MAGNITUDE)
-
-/* PGD bits */
-#define PGDIR_SHIFT    (PTE_SHIFT + PTE_BITS)
 #define PGDIR_SIZE     (1UL << PGDIR_SHIFT)
 #define PGDIR_MASK     (~(PGDIR_SIZE-1))
 
 /* Entries per level */
 #define PTRS_PER_PTE   (PAGE_SIZE / (1 << PTE_MAGNITUDE))
-#define PTRS_PER_PGD   (PAGE_SIZE / sizeof(pgd_t))
 
-#define USER_PTRS_PER_PGD      (TASK_SIZE/PGDIR_SIZE)
 #define FIRST_USER_ADDRESS     0
 
 #define PHYS_ADDR_MASK29               0x1fffffff
diff --git a/arch/sh/include/asm/pgtable_nopmd.h b/arch/sh/include/asm/pgtable_nopmd.h
new file mode 100644 (file)
index 0000000..f0b525b
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef __ASM_SH_PGTABLE_NOPMD_H
+#define __ASM_SH_PGTABLE_NOPMD_H
+
+#include <asm-generic/pgtable-nopmd.h>
+
+/*
+ * traditional two-level paging structure
+ */
+
+/* PTE bits */
+#define PTE_MAGNITUDE  2       /* 32-bit PTEs */
+
+#define PTE_SHIFT      PAGE_SHIFT
+#define PTE_BITS       (PTE_SHIFT - PTE_MAGNITUDE)
+
+/* PGD bits */
+#define PGDIR_SHIFT    (PTE_SHIFT + PTE_BITS)
+
+#define PTRS_PER_PGD   (PAGE_SIZE / (1 << PTE_MAGNITUDE))
+#define USER_PTRS_PER_PGD      (TASK_SIZE/PGDIR_SIZE)
+
+#endif /* __ASM_SH_PGTABLE_NOPMD_H */