powerpc/8xx: Optimisation of TLB handling for IMMR and RAM
v2 cover powerpc/8xx: Optimisation of TLB handling for IMMR and RAM
The purpose of this set of patches is to continue on TLB handling optimisation on the 8xx with the handling of IMMR area as a single 512k area instead of multiple 4k pages.
This set includes a rework of linear RAM mapping in order to not use page table but direct linear mapping. The result is equivalent to the use of BATs on other PPCs and it avoids reading the page table.
This set also includes a rework of the handling of PIN_TLB config option. This option used to be linked to the quantity of RAM available. It is now independant, users having only 8M memory can also use PIN_TLB.
Christophe Leroy (7):
powerpc/8xx: Fix vaddr for IMMR early remap
powerpc/8xx: Map IMMR area with 512k page at a fixed address powerpc/8xx: CONFIG_PIN_TLB unneeded for CONFIG_PPC_EARLY_DEBUG_CPM powerpc/8xx: unpin all TLBs before flushing
powerpc/8xx: Don't use page table for linear memory space powerpc/8xx: Rework CONFIG_PIN_TLB handling
powerpc/8xx: add CONFIG_PIN_TLB_IMMR
arch/powerpc/Kconfig | 5 ++ arch/powerpc/Kconfig.debug | 1 - arch/powerpc/include/asm/fixmap.h | 7 ++ arch/powerpc/kernel/asm-offsets.c | 8 ++ arch/powerpc/kernel/head_8xx.S | 159 +++++++++++++++++++------------------- arch/powerpc/mm/8xx_mmu.c | 131 +++++++++++++++++++++---------- arch/powerpc/mm/mmu_decl.h | 10 ++- arch/powerpc/sysdev/cpm_common.c | 15 +++- 8 files changed, 211 insertions(+), 125 deletions(-)
Signature · 2 lines
v2: Fixed a test in the 6/7 2.1.0
PATCH v2 1/7 powerpc/8xx: Fix vaddr for IMMR early remap
Memory: 124428K/131072K available (3748K kernel code, 188K rwdata, 648K rodata, 508K init, 290K bss, 6644K reserved) Kernel virtual memory layout:
* 0xfffdf000..0xfffff000 : fixmap * 0xfde00000..0xfe000000 : consistent mem * 0xfddf6000..0xfde00000 : early ioremap * 0xc9000000..0xfddf6000 : vmalloc & ioremap
SLUB: HWalign=16, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Today, IMMR is mapped 1:1 at startup
Mapping IMMR 1:1 is just wrong because it may overlap with another area. On most mpc8xx boards it is OK as IMMR is set to 0xff000000 but for instance on EP88xC board, IMMR is at 0xfa200000 which overlaps with VM ioremap area
This patch fixes the virtual address for remapping IMMR with the fixmap regardless of the value of IMMR.
The size of IMMR area is 256kbytes (CPM at offset 0, security engine at offset 128k) so a 512k page is enough
---
v2: No change
arch/powerpc/include/asm/fixmap.h | 7 +++++++ arch/powerpc/kernel/asm-offsets.c | 8 ++++++++ arch/powerpc/kernel/head_8xx.S | 11 ++++++----- arch/powerpc/mm/mmu_decl.h | 7 +++++++ arch/powerpc/sysdev/cpm_common.c | 15 ++++++++++++--- 5 files changed, 40 insertions(+), 8 deletions(-)
arch/powerpc/include/asm/fixmap.h +7 -0
@@ -51,6 +51,13 @@ enum fixed_addresses {FIX_KMAP_BEGIN ,/* reserved pte's for temporary kernel mappings */ FIX_KMAP_END =FIX_KMAP_BEGIN +(KM_TYPE_NR *NR_CPUS )-1 , #endif +#ifdef CONFIG_PPC_8xx + /* For IMMR we need an aligned 512K area */ +#define FIX_IMMR_SIZE (512 * 1024 / PAGE_SIZE) +FIX_IMMR_START , +FIX_IMMR_BASE =__ALIGN_MASK (FIX_IMMR_START ,FIX_IMMR_SIZE -1 ) -1 + +FIX_IMMR_SIZE , +#endif/* FIX_PCIE_MCFG, */ __end_of_fixed_addresses };
arch/powerpc/kernel/asm-offsets.c +8 -0
@@ -68,6 +68,10 @@#include "../mm/mmu_decl.h" #endif +#ifdef CONFIG_PPC_8xx +#include <asm/fixmap.h> +#endif +int main (void ) {DEFINE (THREAD , offsetof(struct task_struct , thread));
@@ -783,5 +787,9 @@ int main(void)DEFINE (PPC_DBELL_SERVER ,PPC_DBELL_SERVER ); +#ifdef CONFIG_PPC_8xx +DEFINE (VIRT_IMMR_BASE ,__fix_to_virt (FIX_IMMR_BASE )); +#endif +return 0 ; }
arch/powerpc/kernel/head_8xx.S +6 -5
@@ -30,6 +30,7 @@ #include <asm/ppc_asm.h> #include <asm/asm-offsets.h> #include <asm/ptrace.h> +#include <asm/fixmap.h> /* Macro to make the code more readable. */ #ifdef CONFIG_8xx_CPU6
@@ -763,7 +764,7 @@ start_here: * virtual to physical. Also, set the cache mode since that is defined * by TLB entries and perform any additional mapping (like of the IMMR). * If configured to pin some TLBs, we pin the first 8 Mbytes of kernel, - * 24 Mbytes of data, and the 8M IMMR space. Anything not covered by + * 24 Mbytes of data, and the 512k IMMR space. Anything not covered by * these mappings is mapped by page tables. */ initial_mmu:
@@ -812,7 +813,7 @@ initial_mmu: ori r8, r8, MD_APG_INIT@l mtspr SPRN_MD_AP, r8 - /* Map another 8 MByte at the IMMR to get the processor + /* Map a 512k page for the IMMR to get the processor * internal registers (among other things). */ #ifdef CONFIG_PIN_TLB
@@ -820,12 +821,12 @@ initial_mmu: mtspr SPRN_MD_CTR, r10 #endif mfspr r9, 638 /* Get current IMMR */ - andis. r9, r9, 0xff80 /* Get 8Mbyte boundary */ + andis. r9, r9, 0xfff8 /* Get 512 kbytes boundary */ - mr r8, r9 /* Create vaddr for TLB */ + lis r8, VIRT_IMMR_BASE@h /* Create vaddr for TLB */ ori r8, r8, MD_EVALID /* Mark it valid */ mtspr SPRN_MD_EPN, r8 - li r8, MD_PS8MEG /* Set 8M byte page */ + li r8, MD_PS512K | MD_GUARDED /* Set 512k byte page */ ori r8, r8, MD_SVALID /* Make it valid */ mtspr SPRN_MD_TWC, r8 mr r8, r9 /* Create paddr for TLB */
arch/powerpc/mm/mmu_decl.h +7 -0
@@ -106,6 +106,13 @@ struct hash_pte;extern struct hash_pte *Hash, *Hash_end;extern unsigned long Hash_size, Hash_mask; +#define PHYS_IMMR_BASE (mfspr(SPRN_IMMR) & 0xfff80000) +#ifdef CONFIG_PPC_8xx +#define VIRT_IMMR_BASE (__fix_to_virt(FIX_IMMR_BASE)) +#else +#define VIRT_IMMR_BASE PHYS_IMMR_BASE +#endif +#endif /* CONFIG_PPC32 */ extern unsigned long ioremap_bot;
arch/powerpc/sysdev/cpm_common.c +12 -3
@@ -28,6 +28,7 @@#include <asm/udbg.h> #include <asm/io.h> #include <asm/cpm.h> +#include <asm/fixmap.h> #include <soc/fsl/qe/qe.h> #include <mm/mmu_decl.h>
@@ -37,12 +38,16 @@#endif #ifdef CONFIG_PPC_EARLY_DEBUG_CPM -static u32 __iomem *cpm_udbg_txdesc = - (u32 __iomem __force *)CONFIG_PPC_EARLY_DEBUG_CPM_ADDR ; +static u32 __iomem *cpm_udbg_txdesc;static void udbg_putc_cpm (char c) { -u8 __iomem *txbuf = (u8 __iomem __force *)in_be32 (&cpm_udbg_txdesc[1 ]); +static u8 __iomem *txbuf; + +if (unlikely (txbuf ==NULL )) + txbuf = (u8 __iomem __force *) + (in_be32 (&cpm_udbg_txdesc[1 ]) -PHYS_IMMR_BASE + +VIRT_IMMR_BASE );if (c =='\n' )udbg_putc_cpm ('\r' );
@@ -56,6 +61,10 @@ static void udbg_putc_cpm(char c)void __init udbg_init_cpm (void ) { + cpm_udbg_txdesc = (u32 __iomem __force *) + (CONFIG_PPC_EARLY_DEBUG_CPM_ADDR -PHYS_IMMR_BASE + +VIRT_IMMR_BASE ); +if (cpm_udbg_txdesc) {#ifdef CONFIG_CPM2 setbat (1 ,0xf0000000 ,0xf0000000 ,1024 *1024 ,PAGE_KERNEL_NCG );
Signature · 1 line
2.1.0
Re: [PATCH v2 1/7] powerpc/8xx: Fix vaddr for IMMR early remap
Quoted 41 lines · Christophe Leroy
Memory: 124428K/131072K available (3748K kernel code, 188K rwdata, 648K rodata, 508K init, 290K bss, 6644K reserved) Kernel virtual memory layout:
* 0xfffdf000..0xfffff000 : fixmap * 0xfde00000..0xfe000000 : consistent mem * 0xfddf6000..0xfde00000 : early ioremap * 0xc9000000..0xfddf6000 : vmalloc & ioremapSLUB: HWalign=16, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Today, IMMR is mapped 1:1 at startup
Mapping IMMR 1:1 is just wrong because it may overlap with another area. On most mpc8xx boards it is OK as IMMR is set to
0xff000000but for instance on EP88xC board, IMMR is at0xfa200000which overlaps with VM ioremap areaThis patch fixes the virtual address for remapping IMMR with the fixmap regardless of the value of IMMR.
The size of IMMR area is 256kbytes (CPM at offset 0, security engine at offset 128k) so a 512k page is enough
Signed-off-by Christophe Leroy <[email protected]>---
v2: No changearch/powerpc/include/asm/fixmap.h | 7 +++++++ arch/powerpc/kernel/asm-offsets.c | 8 ++++++++ arch/powerpc/kernel/head_8xx.S | 11 ++++++----- arch/powerpc/mm/mmu_decl.h | 7 +++++++ arch/powerpc/sysdev/cpm_common.c | 15 ++++++++++++--- 5 files changed, 40 insertions(+), 8 deletions(-)arch/powerpc/include/asm/fixmap.h +0
-0@@ -51,6 +51,13 @@ enum fixed_addresses { FIX_KMAP_BEGIN, /* reserved pte's for temporary kernelmappings */
arch/powerpc/include/asm/fixmap.h enum fixed_addresses { · line 60
Quoted 10 lines
arch/powerpc/include/asm/fixmap.h +8
-0FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,#endif +#ifdef CONFIG_PPC_8xx +/* For IMMR we need an aligned 512K area */ +#define FIX_IMMR_SIZE (512 * 1024 / PAGE_SIZE) +FIX_IMMR_START , +FIX_IMMR_BASE =__ALIGN_MASK (FIX_IMMR_START ,FIX_IMMR_SIZE -1 ) -1 + + + FIX_IMMR_SIZE, +#endif
What happens if FIX_IMMR_START is, for example, 0x100? Then "__ALIGN_MASK(FIX_IMMR_START, FIX_IMMR_SIZE - 1) - 1" would be 0xff -- you've gone backwards. FIX_IMMR_BASE would be 0x17f, translating to an address of 0xffe80000. IMMR would end at 0xfff00000. The kmap range would begin at 0xffeff000 and you'd have an overlap.
I think what you want is:
FIX_IMMR_BASE = (FIX_IMMR_START & ~(FIX_IMMR_SIZE - 1)) + FIX_IMMR_SIZE - 1,
Quoted 83 lines
arch/powerpc/include/asm/fixmap.h +0
-0/* FIX_PCIE_MCFG, */ __end_of_fixed_addresses };arch/powerpc/kernel/asm renamed from arch/powerpc/kernel/asm-offsets.c +0
-1-offsets.cindex 9ea0955..2652233 100644
arch/powerpc/kernel/asm-offsets.c +8
-0@@ -68,6 +68,10 @@#include "../mm/mmu_decl.h" #endif +#ifdef CONFIG_PPC_8xx +#include <asm/fixmap.h> +#endif +int main (void ) {DEFINE (THREAD , offsetof(struct task_struct , thread));@@ -783,5 +787,9 @@ int main(void)DEFINE (PPC_DBELL_SERVER ,PPC_DBELL_SERVER ); +#ifdef CONFIG_PPC_8xx +DEFINE (VIRT_IMMR_BASE ,__fix_to_virt (FIX_IMMR_BASE )); +#endif +return 0 ; }arch/powerpc/kernel/head_8xx.S +4
-3@@ -30,6 +30,7 @@ #include <asm/ppc_asm.h> #include <asm/asm-offsets.h> #include <asm/ptrace.h> +#include <asm/fixmap.h> /* Macro to make the code more readable. */ #ifdef CONFIG_8xx_CPU6@@ -763,7 +764,7 @@ start_here: * virtual to physical. Also, set the cache mode since that is defined * by TLB entries and perform any additional mapping (like of the IMMR). * If configured to pin some TLBs, we pin the first 8 Mbytes of kernel, - * 24 Mbytes of data, and the 8M IMMR space. Anything not covered by + * 24 Mbytes of data, and the 512k IMMR space. Anything not covered by * these mappings is mapped by page tables. */ initial_mmu:@@ -812,7 +813,7 @@ initial_mmu: ori r8, r8, MD_APG_INIT@l mtspr SPRN_MD_AP, r8 - /* Map another 8 MByte at the IMMR to get the processor + /* Map a 512k page for the IMMR to get the processor * internal registers (among other things). */ #ifdef CONFIG_PIN_TLB@@ -820,12 +821,12 @@ initial_mmu: mtspr SPRN_MD_CTR, r10 #endif mfspr r9, 638 /* Get current IMMR */ - andis. r9, r9, 0xff80 /* Get 8Mbyte boundary */ + andis. r9, r9, 0xfff8 /* Get 512 kbytesboundary */
arch/powerpc/kernel/head_8xx.S +2
-2- mr r8, r9 /* Create vaddr for TLB */ + lis r8, VIRT_IMMR_BASE@h /* Create vaddr for TLB */ ori r8, r8, MD_EVALID /* Mark it valid */ mtspr SPRN_MD_EPN, r8 - li r8, MD_PS8MEG /* Set 8M byte page */ + li r8, MD_PS512K | MD_GUARDED /* Set 512k byte page*/
arch/powerpc/kernel/head_8xx.S +0
-0ori r8, r8, MD_SVALID /* Make it valid */ mtspr SPRN_MD_TWC, r8 mr r8, r9 /* Create paddr for TLB */arch/powerpc/mm/mmu_decl.h +0
-0
arch/powerpc/mm/mmu_decl.h struct hash_pte; · line 114
Quoted 9 lines
arch/powerpc/mm/mmu_decl.h +6
-0@@ -106,6 +106,13 @@ struct hash_pte;extern struct hash_pte *Hash, *Hash_end;extern unsigned long Hash_size, Hash_mask; +#define PHYS_IMMR_BASE (mfspr(SPRN_IMMR) & 0xfff80000) +#ifdef CONFIG_PPC_8xx +#define VIRT_IMMR_BASE (__fix_to_virt(FIX_IMMR_BASE)) +#else +#define VIRT_IMMR_BASE PHYS_IMMR_BASE +#endif
Where could that definition of PHYS_IMMR_BASE possibly be used other than 8xx?
82xx, 83xx, etc. don't have SPRN_IMMR.
Can you move this into mmu-8xx.h?
Quoted 9 lines
arch/powerpc/mm/mmu_decl.h +1
-3#ifdef CONFIG_PPC_EARLY_DEBUG_CPM -static u32 __iomem *cpm_udbg_txdesc = - (u32 __iomem __force *)CONFIG_PPC_EARLY_DEBUG_CPM_ADDR ; +static u32 __iomem *cpm_udbg_txdesc;static void udbg_putc_cpm (char c) { - u8 __iomem *txbuf = (u8 __iomem __force*)in_be32(&cpm_udbg_txdesc[1]);
arch/powerpc/mm/mmu_decl.h
Quoted 6 lines
arch/powerpc/mm/mmu_decl.h +6
-0+static u8 __iomem *txbuf; + +if (unlikely (txbuf ==NULL )) + txbuf = (u8 __iomem __force *) + (in_be32 (&cpm_udbg_txdesc[1 ]) -PHYS_IMMR_BASE + +VIRT_IMMR_BASE );
You've just broken udbg on 82xx.
Also, please don't use unlikely or other optimizations that make the code harder to read (such as setting txbuf only if it's NULL) in non-performance -critical code.
arch/powerpc/mm/mmu_decl.h static void udbg_putc_cpm(char c) · line 69
Quoted 12 lines
arch/powerpc/mm/mmu_decl.h +5
-0if (c =='\n' )udbg_putc_cpm ('\r' );@@ -56,6 +61,10 @@ static void udbg_putc_cpm(char c)void __init udbg_init_cpm (void ) { + cpm_udbg_txdesc = (u32 __iomem __force *) + (CONFIG_PPC_EARLY_DEBUG_CPM_ADDR -PHYS_IMMR_BASE + + VIRT_IMMR_BASE); +if (cpm_udbg_txdesc) {
If there's an init function why are you doing init-on-first-use in udbg_putc_cpm()?
-Scott
Re: [PATCH v2 1/7] powerpc/8xx: Fix vaddr for IMMR early remap
Quoted 58 lines · Scott Wood
Quoted 43 lines · Christophe Leroy
Memory: 124428K/131072K available (3748K kernel code, 188K rwdata, 648K rodata, 508K init, 290K bss, 6644K reserved) Kernel virtual memory layout:
* 0xfffdf000..0xfffff000 : fixmap * 0xfde00000..0xfe000000 : consistent mem * 0xfddf6000..0xfde00000 : early ioremap * 0xc9000000..0xfddf6000 : vmalloc & ioremapSLUB: HWalign=16, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Today, IMMR is mapped 1:1 at startup
Mapping IMMR 1:1 is just wrong because it may overlap with another area. On most mpc8xx boards it is OK as IMMR is set to
0xff000000but for instance on EP88xC board, IMMR is at0xfa200000which overlaps with VM ioremap areaThis patch fixes the virtual address for remapping IMMR with the fixmap regardless of the value of IMMR.
The size of IMMR area is 256kbytes (CPM at offset 0, security engine at offset 128k) so a 512k page is enough
Signed-off-by Christophe Leroy <[email protected]>---
v2: No changearch/powerpc/include/asm/fixmap.h | 7 +++++++ arch/powerpc/kernel/asm-offsets.c | 8 ++++++++ arch/powerpc/kernel/head_8xx.S | 11 ++++++----- arch/powerpc/mm/mmu_decl.h | 7 +++++++ arch/powerpc/sysdev/cpm_common.c | 15 ++++++++++++--- 5 files changed, 40 insertions(+), 8 deletions(-)arch/powerpc/include/asm/fixmap.h +0
-0@@ -51,6 +51,13 @@ enum fixed_addresses { FIX_KMAP_BEGIN, /* reserved pte's for temporary kernelmappings */
FIX_KMAP_END= FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
#endifarch/powerpc/include/asm/fixmap.h enum fixed_addresses { · line 60
Quoted 8 lines
arch/powerpc/include/asm/fixmap.h +8
-0+#ifdef CONFIG_PPC_8xx +/* For IMMR we need an aligned 512K area */ +#define FIX_IMMR_SIZE (512 * 1024 / PAGE_SIZE) +FIX_IMMR_START , +FIX_IMMR_BASE =__ALIGN_MASK (FIX_IMMR_START ,FIX_IMMR_SIZE -1 ) -1 + + + FIX_IMMR_SIZE, +#endifWhat happens if
FIX_IMMR_STARTis, for example,0x100? Then "__ALIGN_MASK(FIX_IMMR_START, FIX_IMMR_SIZE - 1)- 1" would be0xff-- you've gone backwards.FIX_IMMR_BASEwould be0x17f, translating to an address of0xffe80000. IMMR would end at0xfff00000. The kmap range would begin at0xffeff000and you'd have an overlap.
Quoted 4 lines
I think what you want is:
FIX_IMMR_BASE = (FIX_IMMR_START & ~(FIX_IMMR_SIZE - 1)) + FIX_IMMR_SIZE - 1,
Why would the kmap range begin at 0xffeff000 ?
If FIX_IMMR_START is 0x100, this means FIX_KMAP_END is 0x0ff, so the kmap range should begin at 0xfff00000, shouldn't it ?
Christophe
Re: [PATCH v2 1/7] powerpc/8xx: Fix vaddr for IMMR early remap
Quoted 62 lines · Christophe Leroy
Quoted 61 lines · Scott Wood
Quoted 43 lines · Christophe Leroy
Memory: 124428K/131072K available (3748K kernel code, 188K rwdata, 648K rodata, 508K init, 290K bss, 6644K reserved) Kernel virtual memory layout:
* 0xfffdf000..0xfffff000 : fixmap * 0xfde00000..0xfe000000 : consistent mem * 0xfddf6000..0xfde00000 : early ioremap * 0xc9000000..0xfddf6000 : vmalloc & ioremapSLUB: HWalign=16, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Today, IMMR is mapped 1:1 at startup
Mapping IMMR 1:1 is just wrong because it may overlap with another area. On most mpc8xx boards it is OK as IMMR is set to
0xff000000but for instance on EP88xC board, IMMR is at0xfa200000which overlaps with VM ioremap areaThis patch fixes the virtual address for remapping IMMR with the fixmap regardless of the value of IMMR.
The size of IMMR area is 256kbytes (CPM at offset 0, security engine at offset 128k) so a 512k page is enough
Signed-off-by Christophe Leroy <[email protected]>---
v2: No changearch/powerpc/include/asm/fixmap.h | 7 +++++++ arch/powerpc/kernel/asm-offsets.c | 8 ++++++++ arch/powerpc/kernel/head_8xx.S | 11 ++++++----- arch/powerpc/mm/mmu_decl.h | 7 +++++++ arch/powerpc/sysdev/cpm_common.c | 15 ++++++++++++--- 5 files changed, 40 insertions(+), 8 deletions(-)arch/powerpc/include/asm/fixmap.h +0
-0@@ -51,6 +51,13 @@ enum fixed_addresses { FIX_KMAP_BEGIN, /* reserved pte's for temporary kernelmappings */
FIX_KMAP_END= FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
#endifarch/powerpc/include/asm/fixmap.h enum fixed_addresses { · line 60
Quoted 9 lines
arch/powerpc/include/asm/fixmap.h +8
-1+#ifdef CONFIG_PPC_8xx +/* For IMMR we need an aligned 512K area */ +#define FIX_IMMR_SIZE (512 * 1024 / PAGE_SIZE) +FIX_IMMR_START , + FIX_IMMR_BASE = __ALIGN_MASK(FIX_IMMR_START, FIX_IMMR_SIZE - 1) - 1 + + + FIX_IMMR_SIZE, +#endif What happens if
FIX_IMMR_STARTis, for example,0x100? Then "__ALIGN_MASK(FIX_IMMR_START, FIX_IMMR_SIZE - 1)- 1" would be0xff-- you've
gone backwards.FIX_IMMR_BASEwould be0x17f, translating to an address of0xffe80000. IMMR would end at0xfff00000. The kmap range would begin at0xffeff000and you'd have an overlap.
Quoted 7 lines
Quoted 4 lines
I think what you want is:
FIX_IMMR_BASE = (FIX_IMMR_START & ~(FIX_IMMR_SIZE - 1)) + FIX_IMMR_SIZE - 1,Why would the kmap range begin at
0xffeff000?
IfFIX_IMMR_STARTis0x100, this meansFIX_KMAP_ENDis0x0ff, so the kmap range should begin at0xfff00000, shouldn't it ?
Yeah, I'm not sure what I was thinking in that reply in general.
-Scott
Re: [PATCH v2 1/7] powerpc/8xx: Fix vaddr for IMMR early remap
Quoted 63 lines · Scott Wood
Quoted 62 lines · Christophe Leroy
Quoted 61 lines · Scott Wood
Quoted 43 lines · Christophe Leroy
Memory: 124428K/131072K available (3748K kernel code, 188K rwdata, 648K rodata, 508K init, 290K bss, 6644K reserved) Kernel virtual memory layout:
* 0xfffdf000..0xfffff000 : fixmap * 0xfde00000..0xfe000000 : consistent mem * 0xfddf6000..0xfde00000 : early ioremap * 0xc9000000..0xfddf6000 : vmalloc & ioremapSLUB: HWalign=16, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Today, IMMR is mapped 1:1 at startup
Mapping IMMR 1:1 is just wrong because it may overlap with another area. On most mpc8xx boards it is OK as IMMR is set to
0xff000000but for instance on EP88xC board, IMMR is at0xfa200000which overlaps with VM ioremap areaThis patch fixes the virtual address for remapping IMMR with the fixmap regardless of the value of IMMR.
The size of IMMR area is 256kbytes (CPM at offset 0, security engine at offset 128k) so a 512k page is enough
Signed-off-by Christophe Leroy <[email protected]>---
v2: No changearch/powerpc/include/asm/fixmap.h | 7 +++++++ arch/powerpc/kernel/asm-offsets.c | 8 ++++++++ arch/powerpc/kernel/head_8xx.S | 11 ++++++----- arch/powerpc/mm/mmu_decl.h | 7 +++++++ arch/powerpc/sysdev/cpm_common.c | 15 ++++++++++++--- 5 files changed, 40 insertions(+), 8 deletions(-)arch/powerpc/include/asm/fixmap.h +0
-0@@ -51,6 +51,13 @@ enum fixed_addresses { FIX_KMAP_BEGIN, /* reserved pte's for temporary kernelmappings */
FIX_KMAP_END= FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
#endifarch/powerpc/include/asm/fixmap.h enum fixed_addresses { · line 60
Quoted 9 lines
arch/powerpc/include/asm/fixmap.h +8
-1+#ifdef CONFIG_PPC_8xx +/* For IMMR we need an aligned 512K area */ +#define FIX_IMMR_SIZE (512 * 1024 / PAGE_SIZE) +FIX_IMMR_START , + FIX_IMMR_BASE = __ALIGN_MASK(FIX_IMMR_START, FIX_IMMR_SIZE - 1) - 1 + + + FIX_IMMR_SIZE, +#endif What happens if
FIX_IMMR_STARTis, for example,0x100? Then "__ALIGN_MASK(FIX_IMMR_START, FIX_IMMR_SIZE - 1)- 1" would be0xff-- you've
gone backwards.FIX_IMMR_BASEwould be0x17f, translating to an address of0xffe80000. IMMR would end at0xfff00000. The kmap range would begin at0xffeff000and you'd have an overlap.
Quoted 10 lines
Quoted 7 lines
Quoted 4 lines
I think what you want is:
FIX_IMMR_BASE = (FIX_IMMR_START & ~(FIX_IMMR_SIZE - 1)) + FIX_IMMR_SIZE - 1,Why would the kmap range begin at
0xffeff000?
IfFIX_IMMR_STARTis0x100, this meansFIX_KMAP_ENDis0x0ff, so the kmap range should begin at0xfff00000, shouldn't it ?Yeah, I'm not sure what I was thinking in that reply in general.
I double checked with all possible values between 0 and FIX_IMMR_SIZE and didn't get any overlap. So I left it. I submitted v3 of the patchset taking into account your other comments.
Christophe
---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus
PATCH v2 2/7 powerpc/8xx: Map IMMR area with 512k page at a fixed address
In reply to Christophe LeroyOnce the linear memory space has been mapped with 8Mb pages, as seen in the related commit, we get 11 millions DTLB missed during the reference 600s period. 77% of the misses are on user addresses and 23% are on kernel addresses (1 fourth for linear address space and 3 fourth for virtual address space)
Traditionaly, each driver manages one computer board which has its own components with its own memory maps.
But on embedded chips like the MPC8xx, the SOC has all registers located in the same IO area.
When looking at ioremaps done during startup, we see that many drivers are re-mapping small parts of the IMMR for their own use and all those small pieces gets their own 4k page, amplifying the number of TLB misses: in our system we get 0xff000000 mapped 31 times and 0xff003000 mapped 9 times.
Even if each part of IMMR was mapped only once with 4k pages, it would still be several small mappings towards linear area.
This patch maps the IMMR with a single 512k page.
With this patch applied, the number of DTLB misses during the 10 min period is reduced to 11.8 millions for a duration of 5.8s, which represents 2% of the non-idle time hence yet another 10% reduction.
---
v2: No change
arch/powerpc/kernel/head_8xx.S | 29 ++++++++++++++++++++++ arch/powerpc/mm/8xx_mmu.c | 56 +++++++++++++++++++++++++++++++++++++++++- arch/powerpc/mm/mmu_decl.h | 3 ++- 3 files changed, 86 insertions(+), 2 deletions(-)
arch/powerpc/kernel/head_8xx.S +29 -0
@@ -384,6 +384,27 @@ InstructionTLBMiss: EXCEPTION_EPILOG_0 rfi +/* + * Bottom part of DataStoreTLBMiss handler for IMMR area + * not enough space in the DataStoreTLBMiss area + */ +DTLBMissIMMR: + mtcr r3 + /* Set 512k byte guarded page and mark it valid */ + li r10, MD_PS512K | MD_GUARDED | MD_SVALID + MTSPR_CPU6(SPRN_MD_TWC, r10, r3) + mfspr r10, SPRN_IMMR /* Get current IMMR */ + rlwinm r10, r10, 0, 0xfff80000 /* Get 512 kbytes boundary */ + ori r10, r10, 0xf0 | MD_SPS16K | _PAGE_SHARED | _PAGE_DIRTY | \ + _PAGE_PRESENT | _PAGE_NO_CACHE + MTSPR_CPU6(SPRN_MD_RPN, r10, r3) /* Update TLB entry */ + + li r11, RPN_PATTERN + mfspr r3, SPRN_SPRG_SCRATCH2 + mtspr SPRN_DAR, r11 /* Tag DAR */ + EXCEPTION_EPILOG_0 + rfi + . = 0x1200 DataStoreTLBMiss: mtspr SPRN_SPRG_SCRATCH2, r3
@@ -397,6 +418,14 @@ DataStoreTLBMiss: IS_KERNEL(r11, r10) mfspr r11, SPRN_M_TW /* Get level 1 table */ BRANCH_UNLESS_KERNEL(3f) + + rlwinm r11, r10, 16, 0xfff8 +#ifndef CONFIG_PIN_TLB + cmpli cr0, r11, VIRT_IMMR_BASE@h +_ENTRY(DTLBMiss_jmp) + beq- DTLBMissIMMR +#endif + lis r11, (swapper_pg_dir-PAGE_OFFSET)@ha 3:
arch/powerpc/mm/8xx_mmu.c +55 -1
79 lines not on this page · raw message
arch/powerpc/mm/mmu_decl.h +2 -1
@@ -161,9 +161,10 @@ struct tlbcam { };#endif -#if defined(CONFIG_6xx) || defined(CONFIG_FSL_BOOKE ) +#if defined(CONFIG_6xx) || defined(CONFIG_FSL_BOOKE ) || defined(CONFIG_PPC_8xx)/* 6xx have BATS */ /* FSL_BOOKE have TLBCAM */ +/* 8xx have LTLB */ phys_addr_t v_block_mapped (unsigned long va);unsigned long p_block_mapped (phys_addr_t pa);#else
Signature · 1 line
2.1.0
PATCH v2 3/7 powerpc/8xx: CONFIG_PIN_TLB unneeded for CONFIG_PPC_EARLY_DEBUG_CPM
In reply to Christophe LeroyIMMR is now mapped by a fixed 512k page managed by the TLB miss handler so it is not anymore necessary to PIN TLBs
---
v2: No change
arch/powerpc/Kconfig.debug | 1 - 1 file changed, 1 deletion(-)
arch/powerpc/Kconfig.debug +0 -1
@@ -212,7 +212,6 @@ config PPC_EARLY_DEBUG_40x config PPC_EARLY_DEBUG_CPM bool "Early serial debugging for Freescale CPM-based serial ports" depends on SERIAL_CPM - select PIN_TLB if PPC_8xx help Select this to enable early debugging for Freescale chips using a CPM-based serial port. This assumes that the bootwrapper
Signature · 1 line
2.1.0
PATCH v2 4/7 powerpc/8xx: unpin all TLBs before flushing
In reply to Christophe LeroyBootloader may have pinned some TLB entries so the kernel must unpin them before flushing TLBs with tlbia otherwise pinned TLB entries won't get flushed
---
v2: No change
arch/powerpc/kernel/head_8xx.S | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
arch/powerpc/kernel/head_8xx.S +10 -8
@@ -797,6 +797,14 @@ start_here: * these mappings is mapped by page tables. */ initial_mmu: + li r8, 0 + mtspr SPRN_MI_CTR, r8 /* remove PINNED ITLB entries */ + lis r10, MD_RESETVAL@h +#ifndef CONFIG_8xx_COPYBACK + oris r10, r10, MD_WTDEF@h +#endif + mtspr SPRN_MD_CTR, r10 /* remove PINNED DTLB entries */ + tlbia /* Invalidate all TLB entries */ /* Always pin the first 8 MB ITLB to prevent ITLB misses while mucking around with SRR0/SRR1 in asm
@@ -807,16 +815,10 @@ initial_mmu: mtspr SPRN_MI_CTR, r8 /* Set instruction MMU control */ #ifdef CONFIG_PIN_TLB - lis r10, (MD_RSV4I | MD_RESETVAL)@h + oris r10, r10, MD_RSV4I@h ori r10, r10, 0x1c00 - mr r8, r10 -#else - lis r10, MD_RESETVAL@h -#endif -#ifndef CONFIG_8xx_COPYBACK - oris r10, r10, MD_WTDEF@h -#endif mtspr SPRN_MD_CTR, r10 /* Set data TLB control */ +#endif /* Now map the lower 8 Meg into the TLBs. For this quick hack, * we can load the instruction and data TLB registers with the
Signature · 1 line
2.1.0
PATCH v2 5/7 powerpc/8xx: Don't use page table for linear memory space
In reply to Christophe LeroyInstead of using the first level page table to define mappings for the linear memory space, we can use direct mapping from the TLB handling routines. This has several advantages:
* No need to read the tables at each TLB miss
* No issue in 16k pages mode where the 1st level table maps 64 Mbytes
The size of the available linear space is known at system startup. In order to avoid data access at each TLB miss to know the memory size, the TLB routine is patched at startup with the proper size
This patch provides a 10%-15% improvment of TLB miss handling for kernel addresses
---
v2: No change
arch/powerpc/kernel/head_8xx.S | 71 ++++++++++++++++++++++-------------------- arch/powerpc/mm/8xx_mmu.c | 56 +++++++++++---------------------- 2 files changed, 55 insertions(+), 72 deletions(-)
arch/powerpc/kernel/head_8xx.S +37 -34
@@ -389,52 +389,52 @@ InstructionTLBMiss: * not enough space in the DataStoreTLBMiss area */ DTLBMissIMMR: - mtcr r3 + mtcr r10 /* Set 512k byte guarded page and mark it valid */ li r10, MD_PS512K | MD_GUARDED | MD_SVALID - MTSPR_CPU6(SPRN_MD_TWC, r10, r3) + MTSPR_CPU6(SPRN_MD_TWC, r10, r11) mfspr r10, SPRN_IMMR /* Get current IMMR */ rlwinm r10, r10, 0, 0xfff80000 /* Get 512 kbytes boundary */ ori r10, r10, 0xf0 | MD_SPS16K | _PAGE_SHARED | _PAGE_DIRTY | \ _PAGE_PRESENT | _PAGE_NO_CACHE - MTSPR_CPU6(SPRN_MD_RPN, r10, r3) /* Update TLB entry */ + MTSPR_CPU6(SPRN_MD_RPN, r10, r11) /* Update TLB entry */ li r11, RPN_PATTERN - mfspr r3, SPRN_SPRG_SCRATCH2 mtspr SPRN_DAR, r11 /* Tag DAR */ EXCEPTION_EPILOG_0 rfi . = 0x1200 DataStoreTLBMiss: - mtspr SPRN_SPRG_SCRATCH2, r3 EXCEPTION_PROLOG_0 - mfcr r3 + mfcr r10 /* If we are faulting a kernel address, we have to use the * kernel page tables. */ - mfspr r10, SPRN_MD_EPN - IS_KERNEL(r11, r10) - mfspr r11, SPRN_M_TW /* Get level 1 table */ - BRANCH_UNLESS_KERNEL(3f) - - rlwinm r11, r10, 16, 0xfff8 + mfspr r11, SPRN_MD_EPN + rlwinm r11, r11, 16, 0xfff8 #ifndef CONFIG_PIN_TLB cmpli cr0, r11, VIRT_IMMR_BASE@h +#endif + cmpli cr7, r11, PAGE_OFFSET@h +#ifndef CONFIG_PIN_TLB _ENTRY(DTLBMiss_jmp) beq- DTLBMissIMMR #endif + bge- cr7, 4f - lis r11, (swapper_pg_dir-PAGE_OFFSET)@ha + mfspr r11, SPRN_M_TW /* Get level 1 table */ 3: + mtcr r10 +#ifdef CONFIG_8xx_CPU6 + mtspr SPRN_SPRG_SCRATCH2, r3 +#endif + mfspr r10, SPRN_MD_EPN /* Insert level 1 index */ rlwimi r11, r10, 32 - ((PAGE_SHIFT - 2) << 1), (PAGE_SHIFT - 2) << 1, 29 lwz r11, (swapper_pg_dir-PAGE_OFFSET)@l(r11) /* Get the level 1 entry */ - mtcr r11 - bt- 28,DTLBMiss8M /* bit 28 = Large page (8M) */ - mtcr r3 /* We have a pte table, so load fetch the pte from the table. */
@@ -482,29 +482,30 @@ _ENTRY(DTLBMiss_jmp) MTSPR_CPU6(SPRN_MD_RPN, r10, r3) /* Update TLB entry */ /* Restore registers */ +#ifdef CONFIG_8xx_CPU6 mfspr r3, SPRN_SPRG_SCRATCH2 +#endif mtspr SPRN_DAR, r11 /* Tag DAR */ EXCEPTION_EPILOG_0 rfi -DTLBMiss8M: - mtcr r3 - ori r11, r11, MD_SVALID - MTSPR_CPU6(SPRN_MD_TWC, r11, r3) -#ifdef CONFIG_PPC_16K_PAGES - /* - * In 16k pages mode, each PGD entry defines a 64M block. - * Here we select the 8M page within the block. - */ - rlwimi r11, r10, 0, 0x03800000 -#endif - rlwinm r10, r11, 0, 0xff800000 +4: +_ENTRY(DTLBMiss_cmp) + cmpli cr0, r11, PAGE_OFFSET@h + lis r11, (swapper_pg_dir-PAGE_OFFSET)@ha + bge- 3b + + mtcr r10 + /* Set 8M byte page and mark it valid */ + li r10, MD_PS8MEG | MD_SVALID + MTSPR_CPU6(SPRN_MD_TWC, r10, r11) + mfspr r10, SPRN_MD_EPN + rlwinm r10, r10, 0, 0x0f800000 /* 8xx supports max 256Mb RAM */ ori r10, r10, 0xf0 | MD_SPS16K | _PAGE_SHARED | _PAGE_DIRTY | \ _PAGE_PRESENT - MTSPR_CPU6(SPRN_MD_RPN, r10, r3) /* Update TLB entry */ + MTSPR_CPU6(SPRN_MD_RPN, r10, r11) /* Update TLB entry */ li r11, RPN_PATTERN - mfspr r3, SPRN_SPRG_SCRATCH2 mtspr SPRN_DAR, r11 /* Tag DAR */ EXCEPTION_EPILOG_0 rfi
@@ -583,12 +584,14 @@ FixupDAR:/* Entry point for dcbx workaround. */ IS_KERNEL(r11, r10) mfspr r11, SPRN_M_TW /* Get level 1 table */ BRANCH_UNLESS_KERNEL(3f) + rlwinm r11, r10, 16, 0xfff8 +_ENTRY(FixupDAR_cmp) + cmpli cr7, r11, PAGE_OFFSET@h + blt- cr7, 200f lis r11, (swapper_pg_dir-PAGE_OFFSET)@ha /* Insert level 1 index */ 3: rlwimi r11, r10, 32 - ((PAGE_SHIFT - 2) << 1), (PAGE_SHIFT - 2) << 1, 29 lwz r11, (swapper_pg_dir-PAGE_OFFSET)@l(r11) /* Get the level 1 entry */ - mtcr r11 - bt 28,200f /* bit 28 = Large page (8M) */ rlwinm r11, r11,0,0,19 /* Extract page descriptor page address */ /* Insert level 2 index */ rlwimi r11, r10, 32 - (PAGE_SHIFT - 2), 32 - PAGE_SHIFT, 29
@@ -614,8 +617,8 @@ FixupDAR:/* Entry point for dcbx workaround. */ 141: mfspr r10,SPRN_SPRG_SCRATCH2 b DARFixed /* Nope, go back to normal TLB processing */ - /* concat physical page address(r11) and page offset(r10) */ -200: rlwimi r11, r10, 0, 32 - (PAGE_SHIFT << 1), 31 + /* create physical page address from effective address */ +200: tophys(r11, r10) b 201b 144: mfspr r10, SPRN_DSISR
arch/powerpc/mm/8xx_mmu.c +18 -38
86 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v2 6/7 powerpc/8xx: Rework CONFIG_PIN_TLB handling
In reply to Christophe LeroyOn recent kernels, with some debug options like for instance CONFIG_LOCKDEP, the BSS requires more than 8M memory, allthough the kernel code fits in the first 8M.
Today, it is necessary to activate CONFIG_PIN_TLB to get more than 8M at startup, allthough pinning TLB is not necessary for that.
We could have inconditionaly mapped 16 or 24M bytes at startup but some old hardware only have 8M and mapping non-existing RAM would be an issue due to speculative accesses.
With the preceeding patch however, the TLB entries are populated on demand. By setting up the TLB miss handler to handle up to 24M until the handler is patched for the entire memory space, it is possible to allow access up to more memory without mapping non-existing RAM.
It is therefore not needed anymore to map memory data at all at startup. It will be handled by the TLB miss handler.
One might still want to PIN the IMMR and the first 24M of RAM. It is now possible to do it in the C memory initialisation functions. In addition, we now know how much memory we have when we do it, so we are able to adapt the pining to the real amount of memory available. So boards with less than 24M can now also benefit from PIN_TLB.
---
v2: Fixed a test
arch/powerpc/kernel/head_8xx.S | 44 ++++-------------------------------------- arch/powerpc/mm/8xx_mmu.c | 27 ++++++++++++++++++-------- 2 files changed, 23 insertions(+), 48 deletions(-)
arch/powerpc/kernel/head_8xx.S +4 -40
@@ -491,7 +491,7 @@ _ENTRY(DTLBMiss_jmp) 4: _ENTRY(DTLBMiss_cmp) - cmpli cr0, r11, PAGE_OFFSET@h + cmpli cr0, r11, (PAGE_OFFSET + 0x1800000)@h lis r11, (swapper_pg_dir-PAGE_OFFSET)@ha bge- 3b
@@ -586,7 +586,7 @@ FixupDAR:/* Entry point for dcbx workaround. */ BRANCH_UNLESS_KERNEL(3f) rlwinm r11, r10, 16, 0xfff8 _ENTRY(FixupDAR_cmp) - cmpli cr7, r11, PAGE_OFFSET@h + cmpli cr7, r11, (PAGE_OFFSET + 0x1800000)@h blt- cr7, 200f lis r11, (swapper_pg_dir-PAGE_OFFSET)@ha /* Insert level 1 index */
@@ -823,23 +823,16 @@ initial_mmu: mtspr SPRN_MD_CTR, r10 /* Set data TLB control */ #endif - /* Now map the lower 8 Meg into the TLBs. For this quick hack, - * we can load the instruction and data TLB registers with the - * same values. - */ + /* Now map the lower 8 Meg into the ITLB. */ lis r8, KERNELBASE@h /* Create vaddr for TLB */ ori r8, r8, MI_EVALID /* Mark it valid */ mtspr SPRN_MI_EPN, r8 - mtspr SPRN_MD_EPN, r8 li r8, MI_PS8MEG | (2 << 5) /* Set 8M byte page, APG 2 */ ori r8, r8, MI_SVALID /* Make it valid */ mtspr SPRN_MI_TWC, r8 - li r8, MI_PS8MEG /* Set 8M byte page, APG 0 */ - ori r8, r8, MI_SVALID /* Make it valid */ - mtspr SPRN_MD_TWC, r8 li r8, MI_BOOTINIT /* Create RPN for address 0 */ mtspr SPRN_MI_RPN, r8 /* Store TLB entry */ - mtspr SPRN_MD_RPN, r8 + lis r8, MI_APG_INIT@h /* Set protection modes */ ori r8, r8, MI_APG_INIT@l mtspr SPRN_MI_AP, r8
@@ -851,9 +844,6 @@ initial_mmu: * internal registers (among other things). */ #ifdef CONFIG_PIN_TLB - addi r10, r10, 0x0100 - mtspr SPRN_MD_CTR, r10 -#endif mfspr r9, 638 /* Get current IMMR */ andis. r9, r9, 0xfff8 /* Get 512 kbytes boundary */
@@ -866,32 +856,6 @@ initial_mmu: mr r8, r9 /* Create paddr for TLB */ ori r8, r8, MI_BOOTINIT|0x2 /* Inhibit cache -- Cort */ mtspr SPRN_MD_RPN, r8 - -#ifdef CONFIG_PIN_TLB - /* Map two more 8M kernel data pages. - */ - addi r10, r10, 0x0100 - mtspr SPRN_MD_CTR, r10 - - lis r8, KERNELBASE@h /* Create vaddr for TLB */ - addis r8, r8, 0x0080 /* Add 8M */ - ori r8, r8, MI_EVALID /* Mark it valid */ - mtspr SPRN_MD_EPN, r8 - li r9, MI_PS8MEG /* Set 8M byte page */ - ori r9, r9, MI_SVALID /* Make it valid */ - mtspr SPRN_MD_TWC, r9 - li r11, MI_BOOTINIT /* Create RPN for address 0 */ - addis r11, r11, 0x0080 /* Add 8M */ - mtspr SPRN_MD_RPN, r11 - - addi r10, r10, 0x0100 - mtspr SPRN_MD_CTR, r10 - - addis r8, r8, 0x0080 /* Add 8M */ - mtspr SPRN_MD_EPN, r8 - mtspr SPRN_MD_TWC, r9 - addis r11, r11, 0x0080 /* Add 8M */ - mtspr SPRN_MD_RPN, r11 #endif /* Since the cache is enabled according to the information we
arch/powerpc/mm/8xx_mmu.c +19 -8
@@ -50,16 +50,32 @@ unsigned long p_block_mapped(phys_addr_t pa)return 0 ; } +#define LARGE_PAGE_SIZE_8M (1<<23) +/* * MMU_init_hw does the chip-specific initialization of the MMU hardware. */ void __init MMU_init_hw (void ) { -/* Nothing to do for the time being but keep it similar to other PPC */ +/* PIN up to the 3 first 8Mb after IMMR in DTLB table */ +#ifdef CONFIG_PIN_TLB +unsigned long ctr =mfspr (SPRN_MD_CTR ) &0xfe000000 ; +unsigned long flags =0xf0 |MD_SPS16K | _PAGE_SHARED | _PAGE_DIRTY; +int i; +unsigned long addr =0 ; +unsigned long mem = total_lowmem; + +for (i =29 ; i <32 && mem >=LARGE_PAGE_SIZE_8M ; i++) { +mtspr (SPRN_MD_CTR , ctr | (i <<8 )); +mtspr (SPRN_MD_EPN , (unsigned long )__va (addr) |MD_EVALID ); +mtspr (SPRN_MD_TWC ,MD_PS8MEG |MD_SVALID ); +mtspr (SPRN_MD_RPN , addr | flags | _PAGE_PRESENT); + addr +=LARGE_PAGE_SIZE_8M ; + mem -=LARGE_PAGE_SIZE_8M ; + } +#endif } -#define LARGE_PAGE_SIZE_8M (1<<23) -static void mmu_mapin_immr (void ) {unsigned long p =PHYS_IMMR_BASE ;
@@ -124,13 +140,8 @@ void setup_initial_memory_limit(phys_addr_t first_memblock_base,*/ BUG_ON (first_memblock_base !=0 ); -#ifdef CONFIG_PIN_TLB /* 8xx can only access 24MB at the moment */ memblock_set_current_limit (min_t (u64, first_memblock_size,0x01800000 )); -#else -/* 8xx can only access 8MB at the moment */ -memblock_set_current_limit (min_t (u64, first_memblock_size,0x00800000 )); -#endif }/*
Signature · 1 line
2.1.0
PATCH v2 7/7 powerpc/8xx: add CONFIG_PIN_TLB_IMMR
In reply to Christophe LeroyCONFIG_PIN_TLB maps IMMR area and the first 24 Mbytes of memory. In some circunstances it might be more interesting to not map IMMR and to map 32 Mbytes of memory instead.
Therefore we add config option CONFIG_PIN_TLB_IMMR to select if IMMR shall be pinned or not, hence whether we pin 24 or 32 Mbytes of RAM
---
v2: No change
arch/powerpc/Kconfig | 5 +++++ arch/powerpc/kernel/head_8xx.S | 10 ++++++---- arch/powerpc/mm/8xx_mmu.c | 12 ++++++++---- 3 files changed, 19 insertions(+), 8 deletions(-)
arch/powerpc/Kconfig +5 -0
@@ -1054,6 +1054,11 @@ config CONSISTENT_SIZE config PIN_TLB bool "Pinned Kernel TLBs (860 ONLY)" depends on ADVANCED_OPTIONS && 8xx + +config PIN_TLB_IMMR + bool "Pinned TLB for IMMR" + depends on PIN_TLB + default y endmenu if PPC64
arch/powerpc/kernel/head_8xx.S +6 -4
@@ -414,11 +414,11 @@ DataStoreTLBMiss: */ mfspr r11, SPRN_MD_EPN rlwinm r11, r11, 16, 0xfff8 -#ifndef CONFIG_PIN_TLB +#ifndef CONFIG_PIN_TLB_IMMR cmpli cr0, r11, VIRT_IMMR_BASE@h #endif cmpli cr7, r11, PAGE_OFFSET@h -#ifndef CONFIG_PIN_TLB +#ifndef CONFIG_PIN_TLB_IMMR _ENTRY(DTLBMiss_jmp) beq- DTLBMissIMMR #endif
@@ -819,7 +819,6 @@ initial_mmu: #ifdef CONFIG_PIN_TLB oris r10, r10, MD_RSV4I@h - ori r10, r10, 0x1c00 mtspr SPRN_MD_CTR, r10 /* Set data TLB control */ #endif
@@ -843,7 +842,10 @@ initial_mmu: /* Map a 512k page for the IMMR to get the processor * internal registers (among other things). */ -#ifdef CONFIG_PIN_TLB +#ifdef CONFIG_PIN_TLB_IMMR + ori r10, r10, 0x1c00 + mtspr SPRN_MD_CTR, r10 + mfspr r9, 638 /* Get current IMMR */ andis. r9, r9, 0xfff8 /* Get 512 kbytes boundary */
arch/powerpc/mm/8xx_mmu.c +8 -4
@@ -61,11 +61,15 @@ void __init MMU_init_hw(void)#ifdef CONFIG_PIN_TLB unsigned long ctr =mfspr (SPRN_MD_CTR ) &0xfe000000 ;unsigned long flags =0xf0 |MD_SPS16K | _PAGE_SHARED | _PAGE_DIRTY; -int i; +#ifdef CONFIG_PIN_TLB_IMMR +int i =29 ; +#else +int i =28 ; +#endif unsigned long addr =0 ;unsigned long mem = total_lowmem; -for (i =29 ; i <32 && mem >=LARGE_PAGE_SIZE_8M ; i++) { +for (; i <32 && mem >=LARGE_PAGE_SIZE_8M ; i++) {mtspr (SPRN_MD_CTR , ctr | (i <<8 ));mtspr (SPRN_MD_EPN , (unsigned long )__va (addr) |MD_EVALID );mtspr (SPRN_MD_TWC ,MD_PS8MEG |MD_SVALID );
@@ -88,7 +92,7 @@ static void mmu_mapin_immr(void) }/* Address of instructions to patch */ -#ifndef CONFIG_PIN_TLB +#ifndef CONFIG_PIN_TLB_IMMR extern unsigned int DTLBMiss_jmp;#endif extern unsigned int DTLBMiss_cmp, FixupDAR_cmp;
@@ -109,7 +113,7 @@ unsigned long __init mmu_mapin_ram(unsigned long top)if (__map_without_ltlbs) { mapped =0 ;mmu_mapin_immr (); -#ifndef CONFIG_PIN_TLB +#ifndef CONFIG_PIN_TLB_IMMR patch_instruction (&DTLBMiss_jmp,PPC_INST_NOP );#endif }else {
Signature · 1 line
2.1.0