Skip to contentSkip to conversation

powerpc/47x: allow kernel to be loaded in higher physical memory

PATCH In review Tony Breeds 4 participants 8 messages Jul 5, 2011 – Jul 13, 2011 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 powerpc/47x: allow kernel to be loaded in higher physical memory

From: Dave Kleikamp <[email protected]>

The 44x code (which is shared by 47x) assumes the available physical memory begins at 0x00000000. This is not necessarily the case in an AMP environment.

Support CONFIG_RELOCATABLE for 476 in order to allow the kernel to be loaded into a higher memory range.

---
 arch/powerpc/Kconfig                          |    2 +-
 arch/powerpc/configs/44x/iss476-smp_defconfig |    6 ++--
 arch/powerpc/kernel/head_44x.S                |   42 ++++++++++++++++++++-----
 arch/powerpc/mm/44x_mmu.c                     |   13 ++++++--
 4 files changed, 48 insertions(+), 15 deletions(-)
arch/powerpc/Kconfig +1 -1
index 2729c66..7cef1fc 100644
@@ -841,7 +841,7 @@ config LOWMEM_CAM_NUM
 
 config RELOCATABLE
 	bool "Build a relocatable kernel (EXPERIMENTAL)"
-	depends on EXPERIMENTAL && ADVANCED_OPTIONS && FLATMEM && FSL_BOOKE
+	depends on EXPERIMENTAL && ADVANCED_OPTIONS && FLATMEM && (FSL_BOOKE || PPC_47x)
 	help
 	  This builds a kernel image that is capable of running at the
 	  location the kernel is loaded at (some alignment restrictions may
arch/powerpc/configs/44x/iss476-smp_defconfig +3 -3
index 92f863a..a6eb6ad 100644
@@ -3,8 +3,8 @@ CONFIG_SMP=y
 CONFIG_EXPERIMENTAL=y
 CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
+CONFIG_SPARSE_IRQ=y
 CONFIG_LOG_BUF_SHIFT=14
-CONFIG_SYSFS_DEPRECATED_V2=y
 CONFIG_BLK_DEV_INITRD=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_EXPERT=y
@@ -21,10 +21,11 @@ CONFIG_ISS4xx=y
 CONFIG_HZ_100=y
 CONFIG_MATH_EMULATION=y
 CONFIG_IRQ_ALL_CPUS=y
-CONFIG_SPARSE_IRQ=y
 CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="root=/dev/issblk0"
 # CONFIG_PCI is not set
+CONFIG_ADVANCED_OPTIONS=y
+CONFIG_RELOCATABLE=y
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_UNIX=y
@@ -67,7 +68,6 @@ CONFIG_EXT3_FS=y
 # CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
 CONFIG_EXT3_FS_POSIX_ACL=y
 CONFIG_EXT3_FS_SECURITY=y
-CONFIG_INOTIFY=y
 CONFIG_PROC_KCORE=y
 CONFIG_TMPFS=y
 CONFIG_CRAMFS=y
arch/powerpc/kernel/head_44x.S +34 -8

72 lines not on this page · raw message

arch/powerpc/mm/44x_mmu.c +10 -3
index 024acab..f60e006 100644
@@ -186,10 +186,11 @@ void __init MMU_init_hw(void)
 unsigned long __init mmu_mapin_ram(unsigned long top)
 {
 	unsigned long addr;
+	unsigned long memstart = memstart_addr & ~(PPC_PIN_SIZE - 1);
 
 	/* Pin in enough TLBs to cover any lowmem not covered by the
 	 * initial 256M mapping established in head_44x.S */
-	for (addr = PPC_PIN_SIZE; addr < lowmem_end_addr;
+	for (addr = memstart + PPC_PIN_SIZE; addr < lowmem_end_addr;
 	     addr += PPC_PIN_SIZE) {
 		if (mmu_has_feature(MMU_FTR_TYPE_47x))
 			ppc47x_pin_tlb(addr + PAGE_OFFSET, addr);
@@ -218,19 +219,25 @@ unsigned long __init mmu_mapin_ram(unsigned long top)
 void setup_initial_memory_limit(phys_addr_t first_memblock_base,
 				phys_addr_t first_memblock_size)
 {
+	u64 size;
+
+#ifndef CONFIG_RELOCATABLE
 	/* We don't currently support the first MEMBLOCK not mapping 0
 	 * physical on those processors
 	 */
 	BUG_ON(first_memblock_base != 0);
+#endif
 
 	/* 44x has a 256M TLB entry pinned at boot */
-	memblock_set_current_limit(min_t(u64, first_memblock_size, PPC_PIN_SIZE));
+	size = (min_t(u64, first_memblock_size, PPC_PIN_SIZE));
+	memblock_set_current_limit(first_memblock_base + size);
 }
 
 #ifdef CONFIG_SMP
 void __cpuinit mmu_init_secondary(int cpu)
 {
 	unsigned long addr;
+	unsigned long memstart = memstart_addr & ~(PPC_PIN_SIZE - 1);
 
 	/* Pin in enough TLBs to cover any lowmem not covered by the
 	 * initial 256M mapping established in head_44x.S
@@ -241,7 +248,7 @@ void __cpuinit mmu_init_secondary(int cpu)
 	 * stack. current (r2) isn't initialized, smp_processor_id()
 	 * will not work, current thread info isn't accessible, ...
 	 */
-	for (addr = PPC_PIN_SIZE; addr < lowmem_end_addr;
+	for (addr = memstart + PPC_PIN_SIZE; addr < lowmem_end_addr;
 	     addr += PPC_PIN_SIZE) {
 		if (mmu_has_feature(MMU_FTR_TYPE_47x))
 			ppc47x_pin_tlb(addr + PAGE_OFFSET, addr);
Signature · 1 line
1.7.4.4
#1 lore raw

PATCH 2/3 powerpc/44x: don't use tlbivax on AMP systems

From: Dave Kleikamp <[email protected]>

Since other OS's may be running on the other cores don't use tlbivax

---
 arch/powerpc/include/asm/mmu.h |    7 ++++++-
 arch/powerpc/kernel/setup_32.c |    2 ++
 arch/powerpc/mm/tlb_hash32.c   |    4 ++++
 arch/powerpc/mm/tlb_nohash.c   |   19 +++++++++++++++++++
 4 files changed, 31 insertions(+), 1 deletions(-)
arch/powerpc/include/asm/mmu.h +6 -1
index 4138b21..bb5591f 100644
@@ -120,9 +120,14 @@ static inline int mmu_has_feature(unsigned long feature)
 	return (cur_cpu_spec->mmu_features & feature);
 }
 
+static inline void mmu_clear_feature(unsigned long feature)
+{
+	cur_cpu_spec->mmu_features &= ~feature;
+}
+
 extern unsigned int __start___mmu_ftr_fixup, __stop___mmu_ftr_fixup;
 
-/* MMU initialization (64-bit only fo now) */
+/* MMU initialization */
 extern void early_init_mmu(void);
 extern void early_init_mmu_secondary(void);
 
arch/powerpc/kernel/setup_32.c +2 -0
index 620d792..6bae164 100644
@@ -127,6 +127,8 @@ notrace void __init machine_init(unsigned long dt_ptr)
 	/* Do some early initialization based on the flat device tree */
 	early_init_devtree(__va(dt_ptr));
 
+	early_init_mmu();
+
 	probe_machine();
 
 	setup_kdump_trampoline();
arch/powerpc/mm/tlb_hash32.c +4 -0
index 27b863c..9a445f6 100644
@@ -177,3 +177,7 @@ void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
 	flush_range(vma->vm_mm, start, end);
 }
 EXPORT_SYMBOL(flush_tlb_range);
+
+void __init early_init_mmu(void)
+{
+}
arch/powerpc/mm/tlb_nohash.c +19 -0
index 0bdad3a..04990b9 100644
@@ -35,6 +35,7 @@
 #include <linux/preempt.h>
 #include <linux/spinlock.h>
 #include <linux/memblock.h>
+#include <linux/of_fdt.h>
 
 #include <asm/tlbflush.h>
 #include <asm/tlb.h>
@@ -266,6 +267,17 @@ EXPORT_SYMBOL(flush_tlb_page);
 
 #endif /* CONFIG_SMP */
 
+#ifdef CONFIG_PPC_47x
+void __init early_init_mmu_47x(void)
+{
+#ifdef CONFIG_SMP
+	unsigned long root = of_get_flat_dt_root();
+	if (of_get_flat_dt_prop(root, "cooperative-partition", NULL))
+		mmu_clear_feature(MMU_FTR_USE_TLBIVAX_BCAST);
+#endif /* CONFIG_SMP */
+}
+#endif /* CONFIG_PPC_47x */
+
 /*
  * Flush kernel TLB entries in the given range
  */
@@ -584,4 +596,11 @@ void setup_initial_memory_limit(phys_addr_t first_memblock_base,
 	/* Finally limit subsequent allocations */
 	memblock_set_current_limit(first_memblock_base + ppc64_rma_size);
 }
+#else /* ! CONFIG_PPC64 */
+void __init early_init_mmu(void)
+{
+#ifdef CONFIG_PPC_47x
+	early_init_mmu_47x();
+#endif
+}
 #endif /* CONFIG_PPC64 */
Signature · 1 line
1.7.4.4
#4 lore raw

PATCH 3/3 powerpc/44x: boot wrapper: allow kernel to load into non-zero address

In reply to Tony Breeds

From: Dave Kleikamp <[email protected]>

For AMP, different kernel instances load into separate memory regions. Read the start of memory from the device tree and limit the memory to what's specified in the device tree.

---
 arch/powerpc/boot/treeboot-iss4xx.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)
arch/powerpc/boot/treeboot-iss4xx.c +22 -1
index fcc4495..329e710 100644
@@ -34,9 +34,29 @@
 
 BSS_STACK(4096);
 
+static u32 ibm4xx_memstart;
+
 static void iss_4xx_fixups(void)
 {
-	ibm4xx_sdram_fixup_memsize();
+	void *memory;
+	u32 reg[3];
+
+	memory = finddevice("/memory");
+	if (!memory)
+		fatal("Can't find memory node\n");
+	/* This assumes #address-cells = 2, #size-cells =1 and that */
+	getprop(memory, "reg", reg, sizeof(reg));
+	if (reg[2])
+		/* If the device tree specifies the memory range, use it */
+		ibm4xx_memstart = reg[1];
+	else
+		/* othersize, read it from the SDRAM controller */
+		ibm4xx_sdram_fixup_memsize();
+}
+
+static void *iss_4xx_vmlinux_alloc(unsigned long size)
+{
+	return (void *)ibm4xx_memstart;
 }
 
 #define SPRN_PIR	0x11E	/* Processor Indentification Register */
@@ -48,6 +68,7 @@ void platform_init(void)
 
 	simple_alloc_init(_end, avail_ram, 128, 64);
 	platform_ops.fixups = iss_4xx_fixups;
+	platform_ops.vmlinux_alloc = iss_4xx_vmlinux_alloc;
 	platform_ops.exit = ibm44x_dbcr_reset;
 	pir_reg = mfspr(SPRN_PIR);
 	fdt_set_boot_cpuid_phys(_dtb_start, pir_reg);
Signature · 1 line
1.7.4.4
#5 lore raw
In reply to Tony Breeds
Quoted 8 lines · Tony Breeds

From: Dave Kleikamp<[email protected]>

The 44x code (which is shared by 47x) assumes the available physical memory begins at 0x00000000. This is not necessarily the case in an AMP environment.

Support CONFIG_RELOCATABLE for 476 in order to allow the kernel to be loaded into a higher memory range.

I think the code assumes, the kernel is loaded in 256M aligned page. You may want to mention that in the description here.

Thanks
Suzuki

#6 lore raw
Quoted 9 lines · Suzuki Poulose
Quoted 8 lines · Tony Breeds

From: Dave Kleikamp<[email protected]>

The 44x code (which is shared by 47x) assumes the available physical memory
begins at 0x00000000. =A0This is not necessarily the case in an AMP environment.

Quoted 4 lines
Quoted 2 lines

Support CONFIG_RELOCATABLE for 476 in order to allow the kernel to be loaded into a higher memory range.

I think the code assumes, the kernel is loaded in 256M aligned page. You =

may

Quoted 1 line

want to mention that in the description here.

Suzie, do you have any other concerns with this code in regards to your kexec/kdump work for 4xx? It seems fairly self-contained to me, so I'd like to apply it but I want to make sure it is not going to majorly conflict with the work you're doing.

josh

#7 lore raw
Quoted 13 lines · Josh Boyer
Quoted 12 lines · Suzuki Poulose
Quoted 10 lines · Tony Breeds

From: Dave Kleikamp<[email protected]>

The 44x code (which is shared by 47x) assumes the available physical memory
begins at 0x00000000. This is not necessarily the case in an AMP environment.

Support CONFIG_RELOCATABLE for 476 in order to allow the kernel to be loaded into a higher memory range.

Quoted 7 lines
Quoted 2 lines

I think the code assumes, the kernel is loaded in 256M aligned page. You may want to mention that in the description here.

Suzie, do you have any other concerns with this code in regards to your kexec/kdump work for 4xx? It seems fairly self-contained to me, so I'd like to apply it but I want to make sure it is not going to majorly conflict with the work you're doing.

Please go ahead.

Thanks
Suzuki

#2 lore raw

Re: [PATCH 2/3] powerpc/44x: don't use tlbivax on AMP systems

In reply to Tony Breeds

arch/powerpc/mm/tlb_nohash.c EXPORT_SYMBOL(flush_tlb_page); · line 280

Quoted 11 lines · Tony Breeds
arch/powerpc/mm/tlb_nohash.c +11 -0
+#ifdef CONFIG_PPC_47x
+void __init early_init_mmu_47x(void)
+{
+#ifdef CONFIG_SMP
+	unsigned long root = of_get_flat_dt_root();
+	if (of_get_flat_dt_prop(root, "cooperative-partition", NULL))
+		mmu_clear_feature(MMU_FTR_USE_TLBIVAX_BCAST);
+#endif /* CONFIG_SMP */
+}
+#endif /* CONFIG_PPC_47x */
+

Is this device tree prop spec'd anywhere?

- k

#3 lore raw

Re: [PATCH 2/3] powerpc/44x: don't use tlbivax on AMP systems

Quoted 16 lines · Kumar Gala

arch/powerpc/mm/tlb_nohash.c EXPORT_SYMBOL(flush_tlb_page); · line 280

Quoted 11 lines · Tony Breeds
arch/powerpc/mm/tlb_nohash.c +11 -0
+#ifdef CONFIG_PPC_47x
+void __init early_init_mmu_47x(void)
+{
+#ifdef CONFIG_SMP
+	unsigned long root = of_get_flat_dt_root();
+	if (of_get_flat_dt_prop(root, "cooperative-partition", NULL))
+		mmu_clear_feature(MMU_FTR_USE_TLBIVAX_BCAST);
+#endif /* CONFIG_SMP */
+}
+#endif /* CONFIG_PPC_47x */
+

Is this device tree prop spec'd anywhere?

I don't think this has been formally written up, but this was discussed in Feb. this year http://patchwork.ozlabs.org/patch/81355/

Yours Tony