Skip to content

Commit f86ef74

Browse files
chleroyScott Wood
authored andcommitted
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 Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Scott Wood <oss@buserror.net>
1 parent c223c90 commit f86ef74

5 files changed

Lines changed: 41 additions & 10 deletions

File tree

‎arch/powerpc/include/asm/fixmap.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ enum fixed_addresses {
5050
#ifdef CONFIG_HIGHMEM
5151
FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
5252
FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
53+
#endif
54+
#ifdef CONFIG_PPC_8xx
55+
/* For IMMR we need an aligned 512K area */
56+
#define FIX_IMMR_SIZE (512 * 1024 / PAGE_SIZE)
57+
FIX_IMMR_START,
58+
FIX_IMMR_BASE = __ALIGN_MASK(FIX_IMMR_START, FIX_IMMR_SIZE - 1) - 1 +
59+
FIX_IMMR_SIZE,
5360
#endif
5461
/* FIX_PCIE_MCFG, */
5562
__end_of_fixed_addresses

‎arch/powerpc/include/asm/mmu-8xx.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ typedef struct {
169169
unsigned int active;
170170
unsigned long vdso_base;
171171
} mm_context_t;
172+
173+
#define PHYS_IMMR_BASE (mfspr(SPRN_IMMR) & 0xfff80000)
174+
#define VIRT_IMMR_BASE (__fix_to_virt(FIX_IMMR_BASE))
172175
#endif /* !__ASSEMBLY__ */
173176

174177
#if defined(CONFIG_PPC_4K_PAGES)

‎arch/powerpc/kernel/asm-offsets.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@
6868
#include "../mm/mmu_decl.h"
6969
#endif
7070

71+
#ifdef CONFIG_PPC_8xx
72+
#include <asm/fixmap.h>
73+
#endif
74+
7175
int main(void)
7276
{
7377
DEFINE(THREAD, offsetof(struct task_struct, thread));
@@ -749,5 +753,9 @@ int main(void)
749753

750754
DEFINE(PPC_DBELL_SERVER, PPC_DBELL_SERVER);
751755

756+
#ifdef CONFIG_PPC_8xx
757+
DEFINE(VIRT_IMMR_BASE, __fix_to_virt(FIX_IMMR_BASE));
758+
#endif
759+
752760
return 0;
753761
}

‎arch/powerpc/kernel/head_8xx.S‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <asm/ppc_asm.h>
3131
#include <asm/asm-offsets.h>
3232
#include <asm/ptrace.h>
33+
#include <asm/fixmap.h>
3334

3435
/* Macro to make the code more readable. */
3536
#ifdef CONFIG_8xx_CPU6
@@ -763,7 +764,7 @@ start_here:
763764
* virtual to physical. Also, set the cache mode since that is defined
764765
* by TLB entries and perform any additional mapping (like of the IMMR).
765766
* If configured to pin some TLBs, we pin the first 8 Mbytes of kernel,
766-
* 24 Mbytes of data, and the 8M IMMR space. Anything not covered by
767+
* 24 Mbytes of data, and the 512k IMMR space. Anything not covered by
767768
* these mappings is mapped by page tables.
768769
*/
769770
initial_mmu:
@@ -812,20 +813,20 @@ initial_mmu:
812813
ori r8, r8, MD_APG_INIT@l
813814
mtspr SPRN_MD_AP, r8
814815

815-
/* Map another 8 MByte at the IMMR to get the processor
816+
/* Map a 512k page for the IMMR to get the processor
816817
* internal registers (among other things).
817818
*/
818819
#ifdef CONFIG_PIN_TLB
819820
addi r10, r10, 0x0100
820821
mtspr SPRN_MD_CTR, r10
821822
#endif
822823
mfspr r9, 638 /* Get current IMMR */
823-
andis. r9, r9, 0xff80 /* Get 8Mbyte boundary */
824+
andis. r9, r9, 0xfff8 /* Get 512 kbytes boundary */
824825

825-
mr r8, r9 /* Create vaddr for TLB */
826+
lis r8, VIRT_IMMR_BASE@h /* Create vaddr for TLB */
826827
ori r8, r8, MD_EVALID /* Mark it valid */
827828
mtspr SPRN_MD_EPN, r8
828-
li r8, MD_PS8MEG /* Set 8M byte page */
829+
li r8, MD_PS512K | MD_GUARDED /* Set 512k byte page */
829830
ori r8, r8, MD_SVALID /* Make it valid */
830831
mtspr SPRN_MD_TWC, r8
831832
mr r8, r9 /* Create paddr for TLB */

‎arch/powerpc/sysdev/cpm_common.c‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <asm/udbg.h>
2929
#include <asm/io.h>
3030
#include <asm/cpm.h>
31+
#include <asm/fixmap.h>
3132
#include <soc/fsl/qe/qe.h>
3233

3334
#include <mm/mmu_decl.h>
@@ -37,25 +38,36 @@
3738
#endif
3839

3940
#ifdef CONFIG_PPC_EARLY_DEBUG_CPM
40-
static u32 __iomem *cpm_udbg_txdesc =
41-
(u32 __iomem __force *)CONFIG_PPC_EARLY_DEBUG_CPM_ADDR;
41+
static u32 __iomem *cpm_udbg_txdesc;
42+
static u8 __iomem *cpm_udbg_txbuf;
4243

4344
static void udbg_putc_cpm(char c)
4445
{
45-
u8 __iomem *txbuf = (u8 __iomem __force *)in_be32(&cpm_udbg_txdesc[1]);
46-
4746
if (c == '\n')
4847
udbg_putc_cpm('\r');
4948

5049
while (in_be32(&cpm_udbg_txdesc[0]) & 0x80000000)
5150
;
5251

53-
out_8(txbuf, c);
52+
out_8(cpm_udbg_txbuf, c);
5453
out_be32(&cpm_udbg_txdesc[0], 0xa0000001);
5554
}
5655

5756
void __init udbg_init_cpm(void)
5857
{
58+
#ifdef CONFIG_PPC_8xx
59+
cpm_udbg_txdesc = (u32 __iomem __force *)
60+
(CONFIG_PPC_EARLY_DEBUG_CPM_ADDR - PHYS_IMMR_BASE +
61+
VIRT_IMMR_BASE);
62+
cpm_udbg_txbuf = (u8 __iomem __force *)
63+
(in_be32(&cpm_udbg_txdesc[1]) - PHYS_IMMR_BASE +
64+
VIRT_IMMR_BASE);
65+
#else
66+
cpm_udbg_txdesc = (u32 __iomem __force *)
67+
CONFIG_PPC_EARLY_DEBUG_CPM_ADDR;
68+
cpm_udbg_txbuf = (u8 __iomem __force *)in_be32(&cpm_udbg_txdesc[1]);
69+
#endif
70+
5971
if (cpm_udbg_txdesc) {
6072
#ifdef CONFIG_CPM2
6173
setbat(1, 0xf0000000, 0xf0000000, 1024*1024, PAGE_KERNEL_NCG);

0 commit comments

Comments
 (0)