Skip to contentSkip to conversation

armv8: fsl-lsch3: Rewrite MMU translation table entries

PATCH Superseded Alison Wang 3 participants 4 messages Aug 3, 2015 – Aug 4, 2015 Arm (32-bit)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 armv8: fsl-lsch3: Rewrite MMU translation table entries

This patch rewrites MMU translation table entries to achieve:
a) Start with all table entries as "invalid".
b) Rewrite the table entries as "device-ngnrne" for cache-inhibit access.
c) Rewrite the table entries as "normal" for cache-enabled access.

---
Changes in v2:
- Rebase the patch.
- Fix build error for emu and emu_D4 defconfig.

 arch/arm/cpu/armv8/cache_v8.c                |  17 +-
 arch/arm/cpu/armv8/fsl-lsch3/README          |  71 ++++
 arch/arm/cpu/armv8/fsl-lsch3/cpu.c           | 462 +++++++++++++++++----------
 arch/arm/include/asm/arch-fsl-lsch3/config.h |   1 +
 arch/arm/include/asm/armv8/mmu.h             |   8 +-
 5 files changed, 380 insertions(+), 179 deletions(-)
arch/arm/cpu/armv8/cache_v8.c +13 -4
index c22f7b6..9a96024 100644
@@ -12,13 +12,22 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifndef CONFIG_SYS_DCACHE_OFF
-void set_pgtable_section(u64 *page_table, u64 index, u64 section,
-			 u64 memory_type)
+inline void set_pgtable_section(u64 *page_table, u64 index, u64 section,
+			 u64 memory_type, u64 share)
 {
 	u64 value;
 
 	value = section | PMD_TYPE_SECT | PMD_SECT_AF;
 	value |= PMD_ATTRINDX(memory_type);
+	value |= share;
+	page_table[index] = value;
+}
+
+inline void set_pgtable_table(u64 *page_table, u64 index, u64 *table_addr)
+{
+	u64 value;
+
+	value = (u64)table_addr | PMD_TYPE_TABLE;
 	page_table[index] = value;
 }
 
@@ -32,7 +41,7 @@ static void mmu_setup(void)
 	/* Setup an identity-mapping for all spaces */
 	for (i = 0; i < (PGTABLE_SIZE >> 3); i++) {
 		set_pgtable_section(page_table, i, i << SECTION_SHIFT,
-				    MT_DEVICE_NGNRNE);
+				    MT_DEVICE_NGNRNE, PMD_SECT_NON_SHARE);
 	}
 
 	/* Setup an identity-mapping for all RAM space */
@@ -42,7 +51,7 @@ static void mmu_setup(void)
 		for (j = start >> SECTION_SHIFT;
 		     j < end >> SECTION_SHIFT; j++) {
 			set_pgtable_section(page_table, j, j << SECTION_SHIFT,
-					    MT_NORMAL);
+					    MT_NORMAL, PMD_SECT_NON_SHARE);
 		}
 	}
 
arch/arm/cpu/armv8/fsl-lsch3/README +71 -0

74 lines not on this page · raw message

arch/arm/cpu/armv8/fsl-lsch3/cpu.c +288 -174

505 lines not on this page · raw message

arch/arm/include/asm/arch-fsl-lsch3/config.h +1 -0
index 8675e91..928bbc9 100644
@@ -18,6 +18,7 @@
 
 #define CONFIG_MP
 #define CONFIG_SYS_FSL_OCRAM_BASE	0x18000000	/* initial RAM */
+#define CONFIG_SYS_FSL_OCRAM_SIZE	0x00200000	/* 2M */
 /* Link Definitions */
 #define CONFIG_SYS_INIT_SP_ADDR		(CONFIG_SYS_FSL_OCRAM_BASE + 0xfff0)
 
arch/arm/include/asm/armv8/mmu.h +7 -1
index 04fa0be..0c928d4 100644
@@ -65,6 +65,7 @@
 /*
  * Section
  */
+#define PMD_SECT_NON_SHARE	(0 << 8)
 #define PMD_SECT_OUTER_SHARE	(2 << 8)
 #define PMD_SECT_INNER_SHARE	(3 << 8)
 #define PMD_SECT_AF		(1 << 10)
@@ -110,8 +111,13 @@
 				TCR_T0SZ(VA_BITS))
 
 #ifndef __ASSEMBLY__
+
 void set_pgtable_section(u64 *page_table, u64 index,
-			 u64 section, u64 memory_type);
+			 u64 section, u64 memory_type,
+			 u64 share);
+void set_pgtable_table(u64 *page_table, u64 index,
+		       u64 *table_addr);
+
 static inline void set_ttbr_tcr_mair(int el, u64 table, u64 tcr, u64 attr)
 {
 	asm volatile("dsb sy");
Signature · 1 line
2.1.0.27.g96db324
#1 lore raw

PATCH v2 1/1 armv8: fsl-lsch3: Rewrite MMU translation table entries

Quoted 6 lines · Alison Wang

This patch rewrites MMU translation table entries to achieve:
a) Start with all table entries as "invalid".
b) Rewrite the table entries as "device-ngnrne" for cache-inhibit access.
c) Rewrite the table entries as "normal" for cache-enabled access.

Quoted 7 lines

---
Changes in v2:
- Rebase the patch.
- Fix build error for emu and emu_D4 defconfig.

Alison,

We don't rewrite the "device-ngnrne" and "normal" separately. I would put the commit message as

This patch rewrites MMU translation table entries. To start, all table entries are written as "invalid", then "device-ngnrnr" and "normal" are written to the entries to enable access to specific addresses.

York

#2 lore raw

PATCH v2 1/1 armv8: fsl-lsch3: Rewrite MMU translation table entries

York,

Quoted 15 lines · Alison Wang
Quoted 6 lines

This patch rewrites MMU translation table entries to achieve:
a) Start with all table entries as "invalid".
b) Rewrite the table entries as "device-ngnrne" for cache-inhibit access.
c) Rewrite the table entries as "normal" for cache-enabled access.

Quoted 7 lines

---
Changes in v2:
- Rebase the patch.
- Fix build error for emu and emu_D4 defconfig.

Quoted 9 lines

Alison,

We don't rewrite the "device-ngnrne" and "normal" separately. I would put the commit message as

This patch rewrites MMU translation table entries. To start, all table entries are written as "invalid", then "device-ngnrnr" and "normal" are written to the entries to enable access to specific addresses.

[Alison Wang] Agree. Thanks.

Best Regards,
Alison Wang

#3 lore raw

PATCH v2 1/1 armv8: fsl-lsch3: Rewrite MMU translation table entries

OK. I will change the commit message. You don't need to send an update.

York

-------- Original message --------
From: Wang Huan-B18965
Date:08/03/2015 19:03 (GMT-08:00)
To: Sun York-R58495 , u-boot at lists.denx.de
Subject: RE: [PATCH v2] armv8: fsl-lsch3: Rewrite MMU translation table entries

York,

Quoted 15 lines · Alison Wang
Quoted 6 lines

This patch rewrites MMU translation table entries to achieve:
a) Start with all table entries as "invalid".
b) Rewrite the table entries as "device-ngnrne" for cache-inhibit access.
c) Rewrite the table entries as "normal" for cache-enabled access.

Quoted 7 lines

---
Changes in v2:
- Rebase the patch.
- Fix build error for emu and emu_D4 defconfig.

Quoted 9 lines

Alison,

We don't rewrite the "device-ngnrne" and "normal" separately. I would put the commit message as

This patch rewrites MMU translation table entries. To start, all table entries are written as "invalid", then "device-ngnrnr" and "normal" are written to the entries to enable access to specific addresses.

[Alison Wang] Agree. Thanks.

Best Regards,
Alison Wang