Skip to contentSkip to conversation

Use scratch register for PGD when MIPS_PGD_C0_CONTEXT is not set

PATCH In review Jayachandran C 3 participants 9 messages Aug 11, 2013 – Sep 25, 2013 MIPS

lore
Share & tools
lore
#0 lore raw

cover Use scratch register for PGD when MIPS_PGD_C0_CONTEXT is not set

These are the two pending patches in this series. I have reordered the changes so that the cleanup patch can be applied first.

The second patch has the changes to use scratch registers when MIPS_PGD_C0_CONTEXT is not defined - this has not changed.

JC.

Jayachandran C (2):
MIPS: Move definition of SMP processor id register to header file
MIPS: mm: Use scratch for PGD when !CONFIG_MIPS_PGD_C0_CONTEXT

 arch/mips/include/asm/mmu_context.h |   22 ++----
 arch/mips/include/asm/stackframe.h  |   24 ++-----
 arch/mips/include/asm/thread_info.h |   33 ++++++++-
 arch/mips/mm/tlbex.c                |  136 +++++++++++++++--------------------
 4 files changed, 103 insertions(+), 112 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/2 MIPS: Move definition of SMP processor id register to header file

The definition of the CP0 register used to save the smp processor id is repicated in many files, move them all to thread_info.h.

---
 arch/mips/include/asm/mmu_context.h |   16 ++++------
 arch/mips/include/asm/stackframe.h  |   24 ++++-----------
 arch/mips/include/asm/thread_info.h |   33 ++++++++++++++++++++-
 arch/mips/mm/tlbex.c                |   56 ++++-------------------------------
 4 files changed, 49 insertions(+), 80 deletions(-)
arch/mips/include/asm/mmu_context.h +5 -11
index 3b29079..ab8e260 100644
@@ -35,10 +35,11 @@ do {									\
 #define TLBMISS_HANDLER_SETUP()						\
 	do {								\
 		TLBMISS_HANDLER_SETUP_PGD(swapper_pg_dir);		\
-		write_c0_xcontext((unsigned long) smp_processor_id() << 51); \
+		write_c0_xcontext((unsigned long) smp_processor_id() <<	\
+						SMP_CPUID_REGSHIFT);	\
 	} while (0)
 
-#else /* CONFIG_MIPS_PGD_C0_CONTEXT: using  pgd_current*/
+#else /* !CONFIG_MIPS_PGD_C0_CONTEXT: using  pgd_current*/
 
 /*
  * For the fast tlb miss handlers, we keep a per cpu array of pointers
@@ -50,18 +51,11 @@ extern unsigned long pgd_current[];
 #define TLBMISS_HANDLER_SETUP_PGD(pgd) \
 	pgd_current[smp_processor_id()] = (unsigned long)(pgd)
 
-#ifdef CONFIG_32BIT
 #define TLBMISS_HANDLER_SETUP()						\
-	write_c0_context((unsigned long) smp_processor_id() << 25);	\
+	write_c0_context((unsigned long) smp_processor_id() <<		\
+						SMP_CPUID_REGSHIFT);	\
 	back_to_back_c0_hazard();					\
 	TLBMISS_HANDLER_SETUP_PGD(swapper_pg_dir)
-#endif
-#ifdef CONFIG_64BIT
-#define TLBMISS_HANDLER_SETUP()						\
-	write_c0_context((unsigned long) smp_processor_id() << 26);	\
-	back_to_back_c0_hazard();					\
-	TLBMISS_HANDLER_SETUP_PGD(swapper_pg_dir)
-#endif
 #endif /* CONFIG_MIPS_PGD_C0_CONTEXT*/
 #if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
 
arch/mips/include/asm/stackframe.h +6 -18
index 23fc95e..4857e2c 100644
@@ -17,6 +17,7 @@
 #include <asm/asmmacro.h>
 #include <asm/mipsregs.h>
 #include <asm/asm-offsets.h>
+#include <asm/thread_info.h>
 
 /*
  * For SMTC kernel, global IE should be left set, and interrupts
@@ -93,21 +94,8 @@
 		.endm
 
 #ifdef CONFIG_SMP
-#ifdef CONFIG_MIPS_MT_SMTC
-#define PTEBASE_SHIFT	19	/* TCBIND */
-#define CPU_ID_REG CP0_TCBIND
-#define CPU_ID_MFC0 mfc0
-#elif defined(CONFIG_MIPS_PGD_C0_CONTEXT)
-#define PTEBASE_SHIFT	48	/* XCONTEXT */
-#define CPU_ID_REG CP0_XCONTEXT
-#define CPU_ID_MFC0 MFC0
-#else
-#define PTEBASE_SHIFT	23	/* CONTEXT */
-#define CPU_ID_REG CP0_CONTEXT
-#define CPU_ID_MFC0 MFC0
-#endif
 		.macro	get_saved_sp	/* SMP variation */
-		CPU_ID_MFC0	k0, CPU_ID_REG
+		ASM_CPUID_MFC0	k0, ASM_SMP_CPUID_REG
 #if defined(CONFIG_32BIT) || defined(KBUILD_64BIT_SYM32)
 		lui	k1, %hi(kernelsp)
 #else
@@ -117,17 +105,17 @@
 		daddiu	k1, %hi(kernelsp)
 		dsll	k1, 16
 #endif
-		LONG_SRL	k0, PTEBASE_SHIFT
+		LONG_SRL	k0, SMP_CPUID_PTRSHIFT
 		LONG_ADDU	k1, k0
 		LONG_L	k1, %lo(kernelsp)(k1)
 		.endm
 
 		.macro	set_saved_sp stackp temp temp2
-		CPU_ID_MFC0	\temp, CPU_ID_REG
-		LONG_SRL	\temp, PTEBASE_SHIFT
+		ASM_CPUID_MFC0	\temp, ASM_SMP_CPUID_REG
+		LONG_SRL	\temp, SMP_CPUID_PTRSHIFT
 		LONG_S	\stackp, kernelsp(\temp)
 		.endm
-#else
+#else /* !CONFIG_SMP */
 		.macro	get_saved_sp	/* Uniprocessor variation */
 #ifdef CONFIG_CPU_JUMP_WORKAROUNDS
 		/*
arch/mips/include/asm/thread_info.h +32 -1
index 61215a3..e0c8cf3 100644
@@ -147,6 +147,37 @@ static inline struct thread_info *current_thread_info(void)
 #define _TIF_ALLWORK_MASK	(_TIF_NOHZ | _TIF_WORK_MASK |		\
 				 _TIF_WORK_SYSCALL_EXIT)
 
-#endif /* __KERNEL__ */
+/*
+ * We stash processor id into a COP0 register to retrieve it fast
+ * at kernel exception entry.
+ */
+#if defined(CONFIG_MIPS_MT_SMTC)
+#define SMP_CPUID_REG		2, 2	/* TCBIND */
+#define ASM_SMP_CPUID_REG	$2, 2
+#define SMP_CPUID_PTRSHIFT	19
+#elif defined(CONFIG_MIPS_PGD_C0_CONTEXT)
+#define SMP_CPUID_REG		20, 0	/* XCONTEXT */
+#define ASM_SMP_CPUID_REG	$20
+#define SMP_CPUID_PTRSHIFT	48
+#else
+#define SMP_CPUID_REG		4, 0	/* CONTEXT */
+#define ASM_SMP_CPUID_REG	$4
+#define SMP_CPUID_PTRSHIFT	23
+#endif
 
+#ifdef CONFIG_64BIT
+#define SMP_CPUID_REGSHIFT	(SMP_CPUID_PTRSHIFT + 3)
+#else
+#define SMP_CPUID_REGSHIFT	(SMP_CPUID_PTRSHIFT + 2)
+#endif
+
+#ifdef CONFIG_MIPS_MT_SMTC
+#define ASM_CPUID_MFC0		mfc0
+#define UASM_i_CPUID_MFC0	uasm_i_mfc0
+#else
+#define ASM_CPUID_MFC0		MFC0
+#define UASM_i_CPUID_MFC0	UASM_i_MFC0
+#endif
+
+#endif /* __KERNEL__ */
 #endif /* _ASM_THREAD_INFO_H */
arch/mips/mm/tlbex.c +6 -50

82 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/2 MIPS: mm: Use scratch for PGD when !CONFIG_MIPS_PGD_C0_CONTEXT

In reply to Jayachandran C

Allow usage of scratch register for current pgd even when MIPS_PGD_C0_CONTEXT is not configured. MIPS_PGD_C0_CONTEXT is set for 64r2 platforms to indicate availability of Xcontext for saving cpuid, thus freeing Context to be used for saving PGD. This option was also tied to using a scratch register for storing PGD.

This commit will allow usage of scratch register to store the current pgd if one can be allocated for the platform, even when MIPS_PGD_C0_CONTEXT is not set. The cpuid will be kept in the CP0 Context register in this case.

The code to store the current pgd for the TLB miss handler is now generated in all cases. When scratch register is available, the PGD is also stored in the scratch register.

---
 arch/mips/include/asm/mmu_context.h |    6 +--
 arch/mips/mm/tlbex.c                |   88 +++++++++++++++++++++++------------
 2 files changed, 58 insertions(+), 36 deletions(-)
arch/mips/include/asm/mmu_context.h +1 -5
index ab8e260..e277bba 100644
@@ -24,14 +24,13 @@
 #endif /* SMTC */
 #include <asm-generic/mm_hooks.h>
 
-#ifdef CONFIG_MIPS_PGD_C0_CONTEXT
-
 #define TLBMISS_HANDLER_SETUP_PGD(pgd)					\
 do {									\
 	extern void tlbmiss_handler_setup_pgd(unsigned long);		\
 	tlbmiss_handler_setup_pgd((unsigned long)(pgd));		\
 } while (0)
 
+#ifdef CONFIG_MIPS_PGD_C0_CONTEXT
 #define TLBMISS_HANDLER_SETUP()						\
 	do {								\
 		TLBMISS_HANDLER_SETUP_PGD(swapper_pg_dir);		\
@@ -48,9 +47,6 @@ do {									\
  */
 extern unsigned long pgd_current[];
 
-#define TLBMISS_HANDLER_SETUP_PGD(pgd) \
-	pgd_current[smp_processor_id()] = (unsigned long)(pgd)
-
 #define TLBMISS_HANDLER_SETUP()						\
 	write_c0_context((unsigned long) smp_processor_id() <<		\
 						SMP_CPUID_REGSHIFT);	\
arch/mips/mm/tlbex.c +57 -31

161 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#3 lore raw

Re: [PATCH 2/2] MIPS: mm: Use scratch for PGD when !CONFIG_MIPS_PGD_C0_CONTEXT

Quoted 6 lines · Jayachandran C

Allow usage of scratch register for current pgd even when MIPS_PGD_C0_CONTEXT is not configured. MIPS_PGD_C0_CONTEXT is set for 64r2 platforms to indicate availability of Xcontext for saving cpuid, thus freeing Context to be used for saving PGD. This option was also tied to using a scratch register for storing PGD.

Quoted 8 lines

This commit will allow usage of scratch register to store the current pgd if one can be allocated for the platform, even when MIPS_PGD_C0_CONTEXT is not set. The cpuid will be kept in the CP0 Context register in this case.

The code to store the current pgd for the TLB miss handler is now generated in all cases. When scratch register is available, the PGD is also stored in the scratch register.

This patch breaks the build for almost all platforms. Amusingly it doesn't break Cavium however which is why I didn't notice it right away.

The build error is the same for all platforms:

[...]
LD init/built-in.o
arch/mips/built-in.o: In function `per_cpu_trap_init':
(.text+0x80e4): undefined reference to tlbmiss_handler_setup_pgd' arch/mips/built-in.o: In function build_setup_pgd':
tlbex.c:(.text+0xe31c): undefined reference to tlbmiss_handler_setup_pgd' tlbex.c:(.text+0xe328): undefined reference to tlbmiss_handler_setup_pgd' tlbex.c:(.text+0xe324): undefined reference to tlbmiss_handler_setup_pgd_end' tlbex.c:(.text+0xe32c): undefined reference to tlbmiss_handler_setup_pgd_end' kernel/built-in.o: In function `__schedule':
core.c:(.sched.text+0x1b74): undefined reference to tlbmiss_handler_setup_pgd' mm/built-in.o: In function use_mm':
(.text+0x1a530): undefined reference to tlbmiss_handler_setup_pgd' fs/built-in.o: In function flush_old_exec':
(.text+0x8da8): undefined reference to `tlbmiss_handler_setup_pgd' make[2]: *** [vmlinux] Error 1
make[1]: *** [sub-make] Error 2
make: *** [all] Error 2
make: Leaving directory `/home/ralf/src/linux/obj/cobalt-build'

I'm reverting the patch now.

Ralf

#4 lore raw

Re: [PATCH 2/2] MIPS: mm: Use scratch for PGD when !CONFIG_MIPS_PGD_C0_CONTEXT

Quoted 42 lines · Ralf Baechle
Quoted 6 lines · Jayachandran C

Allow usage of scratch register for current pgd even when MIPS_PGD_C0_CONTEXT is not configured. MIPS_PGD_C0_CONTEXT is set for 64r2 platforms to indicate availability of Xcontext for saving cpuid, thus freeing Context to be used for saving PGD. This option was also tied to using a scratch register for storing PGD.

Quoted 8 lines

This commit will allow usage of scratch register to store the current pgd if one can be allocated for the platform, even when MIPS_PGD_C0_CONTEXT is not set. The cpuid will be kept in the CP0 Context register in this case.

The code to store the current pgd for the TLB miss handler is now generated in all cases. When scratch register is available, the PGD is also stored in the scratch register.

This patch breaks the build for almost all platforms. Amusingly it doesn't break Cavium however which is why I didn't notice it right away.

The build error is the same for all platforms:

[...]
LD init/built-in.o
arch/mips/built-in.o: In function `per_cpu_trap_init':
(.text+0x80e4): undefined reference to tlbmiss_handler_setup_pgd' arch/mips/built-in.o: In function build_setup_pgd':
tlbex.c:(.text+0xe31c): undefined reference to tlbmiss_handler_setup_pgd' tlbex.c:(.text+0xe328): undefined reference to tlbmiss_handler_setup_pgd' tlbex.c:(.text+0xe324): undefined reference to tlbmiss_handler_setup_pgd_end' tlbex.c:(.text+0xe32c): undefined reference to tlbmiss_handler_setup_pgd_end' kernel/built-in.o: In function `__schedule':
core.c:(.sched.text+0x1b74): undefined reference to tlbmiss_handler_setup_pgd' mm/built-in.o: In function use_mm':
(.text+0x1a530): undefined reference to tlbmiss_handler_setup_pgd' fs/built-in.o: In function flush_old_exec':
(.text+0x8da8): undefined reference to `tlbmiss_handler_setup_pgd' make[2]: *** [vmlinux] Error 1
make[1]: *** [sub-make] Error 2
make: *** [all] Error 2
make: Leaving directory `/home/ralf/src/linux/obj/cobalt-build'

Quoted 1 line

I'm reverting the patch now.

The commit 774b6175 "MIPS: tlbex: Guard tlbmiss_handler_setup_pgd" that went into 3.12-rc1 takes out tlbmiss_handler_setup_pgd definition when CONFIG_MIPS_PGD_C0_CONTEXT is not defined. That clashes with this change and caused the failure.

You can revert 774b6175 before applying this and things should work, I had tested it with qemu on malta as well as on XLP.

JC.

#5 lore raw

Re: [PATCH 2/2] MIPS: mm: Use scratch for PGD when !CONFIG_MIPS_PGD_C0_CONTEXT

Quoted 7 lines · Jayachandran C.

The commit 774b6175 "MIPS: tlbex: Guard tlbmiss_handler_setup_pgd" that went into 3.12-rc1 takes out tlbmiss_handler_setup_pgd definition when CONFIG_MIPS_PGD_C0_CONTEXT is not defined. That clashes with this change and caused the failure.

You can revert 774b6175 before applying this and things should work, I had tested it with qemu on malta as well as on XLP.

Done. Thanks!

Ralf

#6 lore raw

Re: [PATCH 2/2] MIPS: mm: Use scratch for PGD when !CONFIG_MIPS_PGD_C0_CONTEXT

In reply to Jayachandran C
Quoted 11 lines · Jayachandran C

Allow usage of scratch register for current pgd even when MIPS_PGD_C0_CONTEXT is not configured. MIPS_PGD_C0_CONTEXT is set for 64r2 platforms to indicate availability of Xcontext for saving cpuid, thus freeing Context to be used for saving PGD. This option was also tied to using a scratch register for storing PGD.

This commit will allow usage of scratch register to store the current pgd if one can be allocated for the platform, even when MIPS_PGD_C0_CONTEXT is not set. The cpuid will be kept in the CP0 Context register in this case.

Quoted 5 lines

The code to store the current pgd for the TLB miss handler is now generated in all cases. When scratch register is available, the PGD is also stored in the scratch register.

This patch breaks booting for me on bcm47xx. I found this commit by bisecting and then reverted it and it made bcm47xx boot again. The boot
process stops after: [ 0.000000] Inode-cache hash table entries: 4096
(order: 2, 16384 bytes)

The next message would be: [ 0.000000] Writing ErrCtl register=00000000

This issue was seen on bcm4716.

This is the boot log:

CFE> boot -tftp -elf 192.168.1.195:/brcm47xx/openwrt-brcm47xx-vmlinux-initramfs.elf Loader:elf Filesys:tftp Dev:eth0 File:192.168.1.195:/brcm47xx/openwrt-brcm47xx-vmlinux-initramfs.elf Options:(null)
Loading: 0x80001000/4593328 0x804626b0/279760 Entry at 0x80264800 Closing network.
Starting program at 0x80264800

[    0.000000] Linux version 3.12.0-rc1+ (hauke@hauke-desktop) (gcc
version 4.6.4 (OpenWrt/Linaro GCC 4.6-2013.05 r37948) ) #151 Tue Sep 24
23:35:35 CEST 2013
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU revision is: 00019740 (MIPS 74Kc)
[    0.000000] bcm47xx: using bcma bus
[    0.000000] bcma: bus0: Found chip with id 0x4716, rev 0x01 and
package 0x0A
[    0.000000] bcma: bus0: Core 0 found: ChipCommon (manuf 0x4BF, id
0x800, rev 0x1F, class 0x0)
[    0.000000] bcma: bus0: Core 3 found: MIPS 74K (manuf 0x4A7, id
0x82C, rev 0x01, class 0x0)
[    0.000000] bcma: bus0: Found M25P64 serial flash (size: 8192KiB,
blocksize: 0x10000, blocks: 128)
[    0.000000] bcma: bus0: Early bus registered
[    0.000000] MIPS: machine is Netgear WNDR3400 V1
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 04000000 @ 00000000 (usable)
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x00000000-0x03ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x00000000-0x03ffffff]
[    0.000000] Primary instruction cache 32kB, VIPT, 4-way, linesize 32
bytes.
[    0.000000] Primary data cache 32kB, 4-way, VIPT, cache aliases,
linesize 32 bytes
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.
Total pages: 16256
[    0.000000] Kernel command line:  noinitrd console=ttyS0,115200
[    0.000000] PID hash table entries: 256 (order: -2, 1024 bytes)
[    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
#7 lore raw

Re: [PATCH 2/2] MIPS: mm: Use scratch for PGD when !CONFIG_MIPS_PGD_C0_CONTEXT

Quoted 63 lines · Hauke Mehrtens
Quoted 11 lines · Jayachandran C

Allow usage of scratch register for current pgd even when MIPS_PGD_C0_CONTEXT is not configured. MIPS_PGD_C0_CONTEXT is set for 64r2 platforms to indicate availability of Xcontext for saving cpuid, thus freeing Context to be used for saving PGD. This option was also tied to using a scratch register for storing PGD.

This commit will allow usage of scratch register to store the current pgd if one can be allocated for the platform, even when MIPS_PGD_C0_CONTEXT is not set. The cpuid will be kept in the CP0 Context register in this case.

Quoted 5 lines

The code to store the current pgd for the TLB miss handler is now generated in all cases. When scratch register is available, the PGD is also stored in the scratch register.

This patch breaks booting for me on bcm47xx. I found this commit by bisecting and then reverted it and it made bcm47xx boot again. The boot
process stops after: [ 0.000000] Inode-cache hash table entries: 4096
(order: 2, 16384 bytes)

The next message would be: [ 0.000000] Writing ErrCtl register=00000000

This issue was seen on bcm4716.

This is the boot log:

CFE> boot -tftp -elf 192.168.1.195:/brcm47xx/openwrt-brcm47xx-vmlinux-initramfs.elf Loader:elf Filesys:tftp Dev:eth0 File:192.168.1.195:/brcm47xx/openwrt-brcm47xx-vmlinux-initramfs.elf Options:(null)
Loading: 0x80001000/4593328 0x804626b0/279760 Entry at 0x80264800 Closing network.
Starting program at 0x80264800

[    0.000000] Linux version 3.12.0-rc1+ (hauke@hauke-desktop) (gcc
version 4.6.4 (OpenWrt/Linaro GCC 4.6-2013.05 r37948) ) #151 Tue Sep 24
23:35:35 CEST 2013
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU revision is: 00019740 (MIPS 74Kc)
[    0.000000] bcm47xx: using bcma bus
[    0.000000] bcma: bus0: Found chip with id 0x4716, rev 0x01 and
package 0x0A
[    0.000000] bcma: bus0: Core 0 found: ChipCommon (manuf 0x4BF, id
0x800, rev 0x1F, class 0x0)
[    0.000000] bcma: bus0: Core 3 found: MIPS 74K (manuf 0x4A7, id
0x82C, rev 0x01, class 0x0)
[    0.000000] bcma: bus0: Found M25P64 serial flash (size: 8192KiB,
blocksize: 0x10000, blocks: 128)
[    0.000000] bcma: bus0: Early bus registered
[    0.000000] MIPS: machine is Netgear WNDR3400 V1
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 04000000 @ 00000000 (usable)
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x00000000-0x03ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x00000000-0x03ffffff]
[    0.000000] Primary instruction cache 32kB, VIPT, 4-way, linesize 32

bytes.

Quoted 8 lines
[    0.000000] Primary data cache 32kB, 4-way, VIPT, cache aliases,
linesize 32 bytes
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.
Total pages: 16256
[    0.000000] Kernel command line:  noinitrd console=ttyS0,115200
[    0.000000] PID hash table entries: 256 (order: -2, 1024 bytes)
[    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)

Can you please try the attached patch? This patch was made for a slightly older tlbex.c, and seems to have missed this.

Thanks,
JC.

arch/mips/mm/tlbex.c +0 -2
index 73d17f4..fffa7fe 100644
@@ -2180,10 +2180,8 @@ static void flush_tlb_handlers(void)
 			   (unsigned long)handle_tlbs_end);
 	local_flush_icache_range((unsigned long)handle_tlbm,
 			   (unsigned long)handle_tlbm_end);
-#ifdef CONFIG_MIPS_PGD_C0_CONTEXT
 	local_flush_icache_range((unsigned long)tlbmiss_handler_setup_pgd,
 			   (unsigned long)tlbmiss_handler_setup_pgd_end);
-#endif
 }
 
 void build_tlb_refill_handler(void)
#8 lore raw

Re: [PATCH 2/2] MIPS: mm: Use scratch for PGD when !CONFIG_MIPS_PGD_C0_CONTEXT

Quoted 73 lines · Jayachandran C.
Quoted 63 lines · Hauke Mehrtens
Quoted 11 lines · Jayachandran C

Allow usage of scratch register for current pgd even when MIPS_PGD_C0_CONTEXT is not configured. MIPS_PGD_C0_CONTEXT is set for 64r2 platforms to indicate availability of Xcontext for saving cpuid, thus freeing Context to be used for saving PGD. This option was also tied to using a scratch register for storing PGD.

This commit will allow usage of scratch register to store the current pgd if one can be allocated for the platform, even when MIPS_PGD_C0_CONTEXT is not set. The cpuid will be kept in the CP0 Context register in this case.

Quoted 5 lines

The code to store the current pgd for the TLB miss handler is now generated in all cases. When scratch register is available, the PGD is also stored in the scratch register.

This patch breaks booting for me on bcm47xx. I found this commit by bisecting and then reverted it and it made bcm47xx boot again. The boot
process stops after: [ 0.000000] Inode-cache hash table entries: 4096
(order: 2, 16384 bytes)

The next message would be: [ 0.000000] Writing ErrCtl register=00000000

This issue was seen on bcm4716.

This is the boot log:

CFE> boot -tftp -elf 192.168.1.195:/brcm47xx/openwrt-brcm47xx-vmlinux-initramfs.elf Loader:elf Filesys:tftp Dev:eth0 File:192.168.1.195:/brcm47xx/openwrt-brcm47xx-vmlinux-initramfs.elf Options:(null)
Loading: 0x80001000/4593328 0x804626b0/279760 Entry at 0x80264800 Closing network.
Starting program at 0x80264800

[    0.000000] Linux version 3.12.0-rc1+ (hauke@hauke-desktop) (gcc
version 4.6.4 (OpenWrt/Linaro GCC 4.6-2013.05 r37948) ) #151 Tue Sep 24
23:35:35 CEST 2013
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU revision is: 00019740 (MIPS 74Kc)
[    0.000000] bcm47xx: using bcma bus
[    0.000000] bcma: bus0: Found chip with id 0x4716, rev 0x01 and
package 0x0A
[    0.000000] bcma: bus0: Core 0 found: ChipCommon (manuf 0x4BF, id
0x800, rev 0x1F, class 0x0)
[    0.000000] bcma: bus0: Core 3 found: MIPS 74K (manuf 0x4A7, id
0x82C, rev 0x01, class 0x0)
[    0.000000] bcma: bus0: Found M25P64 serial flash (size: 8192KiB,
blocksize: 0x10000, blocks: 128)
[    0.000000] bcma: bus0: Early bus registered
[    0.000000] MIPS: machine is Netgear WNDR3400 V1
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 04000000 @ 00000000 (usable)
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x00000000-0x03ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x00000000-0x03ffffff]
[    0.000000] Primary instruction cache 32kB, VIPT, 4-way, linesize 32

bytes.

Quoted 8 lines
[    0.000000] Primary data cache 32kB, 4-way, VIPT, cache aliases,
linesize 32 bytes
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.
Total pages: 16256
[    0.000000] Kernel command line:  noinitrd console=ttyS0,115200
[    0.000000] PID hash table entries: 256 (order: -2, 1024 bytes)
[    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Quoted 2 lines

Can you please try the attached patch? This patch was made for a slightly older tlbex.c, and seems to have missed this.

Thanks, this patch fixes my problem, could you please summit it for inclusion in upstream-sfr.

Hauke