linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: cyril@ti.com (Cyril Chemparathy)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 08/13] ARM: LPAE: factor out T1SZ and TTBR1 computations
Date: Thu, 31 Jan 2013 16:58:27 -0500	[thread overview]
Message-ID: <1359669512-31276-9-git-send-email-cyril@ti.com> (raw)
In-Reply-To: <1359669512-31276-1-git-send-email-cyril@ti.com>

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>
---
 arch/arm/include/asm/pgtable-3level-hwdef.h |   20 ++++++++++++++++++
 arch/arm/mm/proc-v7-3level.S                |   29 ++++++++-------------------
 2 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
index d795282..e9d70a3 100644
--- a/arch/arm/include/asm/pgtable-3level-hwdef.h
+++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
@@ -74,4 +74,24 @@
 #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
diff --git a/arch/arm/mm/proc-v7-3level.S b/arch/arm/mm/proc-v7-3level.S
index e64be21..e6576f5 100644
--- a/arch/arm/mm/proc-v7-3level.S
+++ b/arch/arm/mm/proc-v7-3level.S
@@ -113,7 +113,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)
@@ -121,27 +121,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
-- 
1.7.9.5

  parent reply	other threads:[~2013-01-31 21:58 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-31 21:58 [PATCH v4 00/13] ARM LPAE Fixes - Part 1 Cyril Chemparathy
2013-01-31 21:58 ` [PATCH v4 01/13] ARM: LPAE: use signed arithmetic for mask definitions Cyril Chemparathy
2013-01-31 21:58 ` [PATCH v4 02/13] ARM: LPAE: use phys_addr_t in alloc_init_pud() Cyril Chemparathy
2013-02-01  3:11   ` Hui Wang
2013-02-01  3:35     ` Nicolas Pitre
2013-02-01  5:40       ` Hui Wang
2013-02-01 17:33       ` Subash Patel
2013-02-01 17:56         ` Cyril Chemparathy
2013-02-01 18:14         ` Nicolas Pitre
2013-02-01 20:32           ` Subash Patel
2013-01-31 21:58 ` [PATCH v4 03/13] ARM: LPAE: use phys_addr_t in free_memmap() Cyril Chemparathy
2013-01-31 21:58 ` [PATCH v4 04/13] ARM: LPAE: use phys_addr_t for initrd location Cyril Chemparathy
2013-01-31 21:58 ` [PATCH v4 05/13] ARM: LPAE: use phys_addr_t in switch_mm() Cyril Chemparathy
2013-01-31 21:58 ` [PATCH v4 06/13] ARM: LPAE: use 64-bit accessors for TTBR registers Cyril Chemparathy
2013-01-31 21:58 ` [PATCH v4 07/13] ARM: LPAE: define ARCH_LOW_ADDRESS_LIMIT for bootmem Cyril Chemparathy
2013-02-01  3:42   ` Nicolas Pitre
2013-01-31 21:58 ` Cyril Chemparathy [this message]
2013-01-31 21:58 ` [PATCH v4 09/13] ARM: LPAE: accomodate >32-bit addresses for page table base Cyril Chemparathy
2013-02-01  3:48   ` Nicolas Pitre
2013-01-31 21:58 ` [PATCH v4 10/13] ARM: mm: use physical addresses in highmem sanity checks Cyril Chemparathy
2013-01-31 21:58 ` [PATCH v4 11/13] ARM: mm: cleanup checks for membank overlap with vmalloc area Cyril Chemparathy
2013-01-31 21:58 ` [PATCH v4 12/13] ARM: mm: clean up membank size limit checks Cyril Chemparathy
2013-01-31 21:58 ` [PATCH v4 13/13] ARM: fix type of PHYS_PFN_OFFSET to unsigned long Cyril Chemparathy
2013-02-01  3:51   ` Nicolas Pitre
2013-02-01  4:00 ` [PATCH v4 00/13] ARM LPAE Fixes - Part 1 Nicolas Pitre
2013-02-01 15:10   ` Cyril Chemparathy
2013-02-01 15:14     ` Russell King - ARM Linux
2013-02-01 16:13       ` Cyril Chemparathy
2013-02-01 17:56         ` Nicolas Pitre
2013-02-01 20:21 ` Subash Patel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1359669512-31276-9-git-send-email-cyril@ti.com \
    --to=cyril@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).