Skip to contentSkip to conversation

ppc/85xx: Add tracking of TLB CAM usage

PATCH New Kumar Gala 1 participant 4 messages Nov 13, 2009

lore
Share & tools
lore

Kumar Gala

author
#0 lore raw

PATCH 1/4 ppc/85xx: Add tracking of TLB CAM usage

We need to track which TLB CAM entries are used to allow us to "dynamically" allocate entries later in the code. For example the SPD DDR code today hard codes which TLB entries it uses. We can now make that pick entries that are free.

---
 cpu/mpc85xx/cpu_init.c        |    1 +
 cpu/mpc85xx/tlb.c             |   62 +++++++++++++++++++++++++++++++++++++++++
 include/asm-ppc/config.h      |    7 ++++
 include/asm-ppc/global_data.h |    3 ++
 include/asm-ppc/mmu.h         |    2 +
 5 files changed, 75 insertions(+), 0 deletions(-)
cpu/mpc85xx/cpu_init.c +1 -0
index 16ce82c..006f36e 100644
@@ -246,6 +246,7 @@ void cpu_init_f (void)
 #ifdef CONFIG_FSL_CORENET
 	corenet_tb_init();
 #endif
+	init_used_tlb_cams();	
 }
 
 
cpu/mpc85xx/tlb.c +62 -0

80 lines not on this page · raw message

include/asm-ppc/config.h +7 -0
index d5f82b4..796707e 100644
@@ -63,6 +63,13 @@
 #define CONFIG_TSECV2
 #endif
 
+/* Number of TLB CAM entries we have on FSL Book-E chips */
+#if defined(CONFIG_E500MC)
+#define CONFIG_SYS_NUM_TLBCAMS	64
+#elif defined(CONFIG_E500)
+#define CONFIG_SYS_NUM_TLBCAMS	16
+#endif
+
 /* Relocation to SDRAM works on all PPC boards */
 #define CONFIG_RELOC_FIXUP_WORKS
 
include/asm-ppc/global_data.h +3 -0
index 55e7e20..3f11918 100644
@@ -107,6 +107,9 @@ typedef	struct	global_data {
 #if defined(CONFIG_FSL_LAW)
 	u32 used_laws;
 #endif
+#if defined(CONFIG_E500)
+	u32 used_tlb_cams[(CONFIG_SYS_NUM_TLBCAMS+31)/32];
+#endif
 #if defined(CONFIG_MPC5xxx)
 	unsigned long	ipb_clk;
 	unsigned long	pci_clk;
include/asm-ppc/mmu.h +2 -0
index ec22a50..fd10249 100644
@@ -479,6 +479,8 @@ extern void disable_tlb(u8 esel);
 extern void invalidate_tlb(u8 tlb);
 extern void init_tlbs(void);
 extern int find_tlb_idx(void *addr, u8 tlbsel);
+extern void init_used_tlb_cams(void);
+extern int find_free_tlbcam(void);
 
 extern unsigned int setup_ddr_tlbs(unsigned int memsize_in_meg);
 
Signature · 1 line
1.6.0.6
author
#1 lore raw

PATCH 2/4 ppc/85xx: Make SPD DDR TLB setup code use dynamic entry allocation

Now that we track which TLB CAM entries are used we can allocate entries on the fly. Change the SPD DDR TLB setup code to assume we use at most 8 TLBs (or the number free, which ever is fewer).

---
 cpu/mpc85xx/tlb.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
cpu/mpc85xx/tlb.c +6 -6
index 54339c4..fb10e27 100644
@@ -225,14 +225,10 @@ void init_addr_map(void)
 }
 #endif
 
-#ifndef CONFIG_SYS_DDR_TLB_START
-#define CONFIG_SYS_DDR_TLB_START 8
-#endif
-
 unsigned int setup_ddr_tlbs(unsigned int memsize_in_meg)
 {
+	int i;
 	unsigned int tlb_size;
-	unsigned int ram_tlb_index = CONFIG_SYS_DDR_TLB_START;
 	unsigned int ram_tlb_address = (unsigned int)CONFIG_SYS_DDR_SDRAM_BASE;
 	unsigned int max_cam = (mfspr(SPRN_TLB1CFG) >> 16) & 0xf;
 	u64 size, memsize = (u64)memsize_in_meg << 20;
@@ -242,10 +238,14 @@ unsigned int setup_ddr_tlbs(unsigned int memsize_in_meg)
 	/* Convert (4^max) kB to (2^max) bytes */
 	max_cam = max_cam * 2 + 10;
 
-	for (; size && ram_tlb_index < 16; ram_tlb_index++) {
+	for (i = 0; size && i < 8; i++) {
+		int ram_tlb_index = find_free_tlbcam();
 		u32 camsize = __ilog2_u64(size) & ~1U;
 		u32 align = __ilog2(ram_tlb_address) & ~1U;
 
+		if (ram_tlb_index == -1)
+			break;
+
 		if (align == -2) align = max_cam;
 		if (camsize > align)
 			camsize = align;
Signature · 1 line
1.6.0.6
author
#2 lore raw

PATCH 3/4 ppc/85xx: Remove CONFIG_SYS_DDR_TLB_START

Now that we dynamically determine TLB CAM entries to use we dont need CONFIG_SYS_DDR_TLB_START anymore.

---
 include/configs/MPC8572DS.h |    1 -
 include/configs/P1_P2_RDB.h |    2 --
 include/configs/P2020DS.h   |    1 -
 3 files changed, 0 insertions(+), 4 deletions(-)
include/configs/MPC8572DS.h +0 -1
index 0e7745c..a274815 100644
@@ -98,7 +98,6 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
 #define CONFIG_SYS_PCIE1_ADDR		(CONFIG_SYS_CCSRBAR+0xa000)
 
 /* DDR Setup */
-#define CONFIG_SYS_DDR_TLB_START 9
 #define CONFIG_VERY_BIG_RAM
 #define CONFIG_FSL_DDR2
 #undef CONFIG_FSL_DDR_INTERACTIVE
include/configs/P1_P2_RDB.h +0 -2
index e2930c1..6315bbd 100644
@@ -149,8 +149,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
 #define CONFIG_SYS_DDR_ERR_DIS		0x00000000
 #define CONFIG_SYS_DDR_SBE		0x00FF0000
 
-#define CONFIG_SYS_DDR_TLB_START 9
-
 /*
  * Memory map
  *
include/configs/P2020DS.h +0 -1
index 9574fca..7a6b623 100644
@@ -101,7 +101,6 @@ extern unsigned long calculate_board_ddr_clk(unsigned long dummy);
 #define CONFIG_SYS_PCIE1_ADDR		(CONFIG_SYS_CCSRBAR+0xa000)
 
 /* DDR Setup */
-#define CONFIG_SYS_DDR_TLB_START 9
 #define CONFIG_VERY_BIG_RAM
 #define CONFIG_FSL_DDR3		1
 #undef CONFIG_FSL_DDR_INTERACTIVE
Signature · 1 line
1.6.0.6
author
#3 lore raw

PATCH 4/4 ppc/85xx: Make flash TLB entry determined at runtime on FSL boards

Rather than hard coding which TLB entry the FLASH is mapped with we can use find_tlb_idx to determine the entry.

---
 board/freescale/mpc8536ds/mpc8536ds.c |    2 +-
 board/freescale/mpc8572ds/mpc8572ds.c |    2 +-
 board/freescale/p1_p2_rdb/p1_p2_rdb.c |    2 +-
 board/freescale/p2020ds/p2020ds.c     |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
board/freescale/mpc8536ds/mpc8536ds.c +1 -1
index ce40cdb..f8292cf 100644
@@ -313,7 +313,7 @@ void pci_init_board(void)
 int board_early_init_r(void)
 {
 	const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
-	const u8 flash_esel = 1;
+	const u8 flash_esel = find_tlb_idx((void *)flashbase, 1);
 
 	/*
 	 * Remap Boot flash + PROMJET region to caching-inhibited
board/freescale/mpc8572ds/mpc8572ds.c +1 -1
index 556846a..64e164b 100644
@@ -264,7 +264,7 @@ void pci_init_board(void)
 int board_early_init_r(void)
 {
 	const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
-	const u8 flash_esel = 2;
+	const u8 flash_esel = find_tlb_idx((void *)flashbase, 1);
 
 	/*
 	 * Remap Boot flash + PROMJET region to caching-inhibited
board/freescale/p1_p2_rdb/p1_p2_rdb.c +1 -1
index 4c03468..3af660e 100644
@@ -131,7 +131,7 @@ int checkboard (void)
 int board_early_init_r(void)
 {
 	const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
-	const u8 flash_esel = 2;
+	const u8 flash_esel = find_tlb_idx((void *)flashbase, 1);
 
 	/*
 	 * Remap Boot flash region to caching-inhibited
board/freescale/p2020ds/p2020ds.c +1 -1
index aecb7aa..599caa2 100644
@@ -298,7 +298,7 @@ void pci_init_board(void)
 int board_early_init_r(void)
 {
 	const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
-	const u8 flash_esel = 2;
+	const u8 flash_esel = find_tlb_idx((void *)flashbase, 1);
 
 	/*
 	 * Remap Boot flash + PROMJET region to caching-inhibited
Signature · 1 line
1.6.0.6