ARM: LPAE: factor out T1SZ and TTBR1 computations
authorCyril Chemparathy <cyril@ti.com>
Sat, 21 Jul 2012 23:47:52 +0000 (19:47 -0400)
committerWill Deacon <will.deacon@arm.com>
Thu, 30 May 2013 15:02:11 +0000 (16:02 +0100)
This patch moves the TTBR1 offset calculation and the T1SZ calculation out
of the TTB setup assembly code.  This should not affect functionality in
any way, but improves code readability as well as readability of subsequent
patches in this series.

Signed-off-by: Cyril Chemparathy <cyril@ti.com>
Signed-off-by: Vitaly Andrianov <vitalya@ti.com>
Acked-by: Nicolas Pitre <nico@linaro.org>
Tested-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Tested-by: Subash Patel <subash.rp@samsung.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm/include/asm/pgtable-3level-hwdef.h
arch/arm/mm/proc-v7-3level.S

index 18f5cef82ad58988e1c8d9b77ab95eb995330bbf..c6c6e6df22f3867f2f79b7471da9508880103800 100644 (file)
 #define PHYS_MASK_SHIFT                (40)
 #define PHYS_MASK              ((1ULL << PHYS_MASK_SHIFT) - 1)
 
+/*
+ * TTBR0/TTBR1 split (PAGE_OFFSET):
+ *   0x40000000: T0SZ = 2, T1SZ = 0 (not used)
+ *   0x80000000: T0SZ = 0, T1SZ = 1
+ *   0xc0000000: T0SZ = 0, T1SZ = 2
+ *
+ * Only use this feature if PHYS_OFFSET <= PAGE_OFFSET, otherwise
+ * booting secondary CPUs would end up using TTBR1 for the identity
+ * mapping set up in TTBR0.
+ */
+#if defined CONFIG_VMSPLIT_2G
+#define TTBR1_OFFSET   16                      /* skip two L1 entries */
+#elif defined CONFIG_VMSPLIT_3G
+#define TTBR1_OFFSET   (4096 * (1 + 3))        /* only L2, skip pgd + 3*pmd */
+#else
+#define TTBR1_OFFSET   0
+#endif
+
+#define TTBR1_SIZE     (((PAGE_OFFSET >> 30) - 1) << 16)
+
 #endif
index 995857d3b530a17318ea1d294936f621de22016d..58ab7477bb615810cb36c1cef8ef073f62a219e3 100644 (file)
@@ -114,7 +114,7 @@ ENDPROC(cpu_v7_set_pte_ext)
         */
        .macro  v7_ttb_setup, zero, ttbr0, ttbr1, tmp
        ldr     \tmp, =swapper_pg_dir           @ swapper_pg_dir virtual address
-       cmp     \ttbr1, \tmp                    @ PHYS_OFFSET > PAGE_OFFSET? (branch below)
+       cmp     \ttbr1, \tmp                    @ PHYS_OFFSET > PAGE_OFFSET?
        mrc     p15, 0, \tmp, c2, c0, 2         @ TTB control register
        orr     \tmp, \tmp, #TTB_EAE
        ALT_SMP(orr     \tmp, \tmp, #TTB_FLAGS_SMP)
@@ -122,27 +122,14 @@ ENDPROC(cpu_v7_set_pte_ext)
        ALT_SMP(orr     \tmp, \tmp, #TTB_FLAGS_SMP << 16)
        ALT_UP(orr      \tmp, \tmp, #TTB_FLAGS_UP << 16)
        /*
-        * TTBR0/TTBR1 split (PAGE_OFFSET):
-        *   0x40000000: T0SZ = 2, T1SZ = 0 (not used)
-        *   0x80000000: T0SZ = 0, T1SZ = 1
-        *   0xc0000000: T0SZ = 0, T1SZ = 2
-        *
-        * Only use this feature if PHYS_OFFSET <= PAGE_OFFSET, otherwise
-        * booting secondary CPUs would end up using TTBR1 for the identity
-        * mapping set up in TTBR0.
+        * Only use split TTBRs if PHYS_OFFSET <= PAGE_OFFSET (cmp above),
+        * otherwise booting secondary CPUs would end up using TTBR1 for the
+        * identity mapping set up in TTBR0.
         */
-       bhi     9001f                           @ PHYS_OFFSET > PAGE_OFFSET?
-       orr     \tmp, \tmp, #(((PAGE_OFFSET >> 30) - 1) << 16) @ TTBCR.T1SZ
-#if defined CONFIG_VMSPLIT_2G
-       /* PAGE_OFFSET == 0x80000000, T1SZ == 1 */
-       add     \ttbr1, \ttbr1, #1 << 4         @ skip two L1 entries
-#elif defined CONFIG_VMSPLIT_3G
-       /* PAGE_OFFSET == 0xc0000000, T1SZ == 2 */
-       add     \ttbr1, \ttbr1, #4096 * (1 + 3) @ only L2 used, skip pgd+3*pmd
-#endif
-       /* CONFIG_VMSPLIT_1G does not need TTBR1 adjustment */
-9001:  mcr     p15, 0, \tmp, c2, c0, 2         @ TTB control register
-       mcrr    p15, 1, \ttbr1, \zero, c2       @ load TTBR1
+       orrls   \tmp, \tmp, #TTBR1_SIZE                         @ TTBCR.T1SZ
+       mcr     p15, 0, \tmp, c2, c0, 2                         @ TTBCR
+       addls   \ttbr1, \ttbr1, #TTBR1_OFFSET
+       mcrr    p15, 1, \ttbr1, \zero, c2                       @ load TTBR1
        .endm
 
        __CPUINIT