aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/prom_init.c
diff options
context:
space:
mode:
authorMichael Ellerman <michael@ellerman.id.au>2006-05-17 04:00:46 -0400
committerPaul Mackerras <paulus@samba.org>2006-05-19 01:02:15 -0400
commit2babf5c2ec2f2d5de3e38d20f7df7fd815fd10c9 (patch)
tree9ecda21067fe36f36fbefae87141150b62c39acd /arch/powerpc/kernel/prom_init.c
parent846f77b08c8301682ded5ce127c56397327a60d0 (diff)
[PATCH] powerpc: Unify mem= handling
We currently do mem= handling in three seperate places. And as benh pointed out I wrote two of them. Now that we parse command line parameters earlier we can clean this mess up. Moving the parsing out of prom_init means the device tree might be allocated above the memory limit. If that happens we'd have to move it. As it happens we already have logic to do that for kdump, so just genericise it. This also means we might have reserved regions above the memory limit, if we do the bootmem allocator will blow up, so we have to modify lmb_enforce_memory_limit() to truncate the reserves as well. Tested on P5 LPAR, iSeries, F50, 44p. Tested moving device tree on P5 and 44p and F50. Signed-off-by: Michael Ellerman <michael@ellerman.id.au> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel/prom_init.c')
-rw-r--r--arch/powerpc/kernel/prom_init.c55
1 files changed, 5 insertions, 50 deletions
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 078fb5533541..a52377c68fc6 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -194,8 +194,6 @@ static int __initdata of_platform;
194 194
195static char __initdata prom_cmd_line[COMMAND_LINE_SIZE]; 195static char __initdata prom_cmd_line[COMMAND_LINE_SIZE];
196 196
197static unsigned long __initdata prom_memory_limit;
198
199static unsigned long __initdata alloc_top; 197static unsigned long __initdata alloc_top;
200static unsigned long __initdata alloc_top_high; 198static unsigned long __initdata alloc_top_high;
201static unsigned long __initdata alloc_bottom; 199static unsigned long __initdata alloc_bottom;
@@ -594,16 +592,6 @@ static void __init early_cmdline_parse(void)
594 } 592 }
595#endif 593#endif
596 594
597 opt = strstr(RELOC(prom_cmd_line), RELOC("mem="));
598 if (opt) {
599 opt += 4;
600 RELOC(prom_memory_limit) = prom_memparse(opt, (const char **)&opt);
601#ifdef CONFIG_PPC64
602 /* Align to 16 MB == size of ppc64 large page */
603 RELOC(prom_memory_limit) = ALIGN(RELOC(prom_memory_limit), 0x1000000);
604#endif
605 }
606
607#ifdef CONFIG_KEXEC 595#ifdef CONFIG_KEXEC
608 /* 596 /*
609 * crashkernel=size@addr specifies the location to reserve for 597 * crashkernel=size@addr specifies the location to reserve for
@@ -1115,29 +1103,6 @@ static void __init prom_init_mem(void)
1115 } 1103 }
1116 1104
1117 /* 1105 /*
1118 * If prom_memory_limit is set we reduce the upper limits *except* for
1119 * alloc_top_high. This must be the real top of RAM so we can put
1120 * TCE's up there.
1121 */
1122
1123 RELOC(alloc_top_high) = RELOC(ram_top);
1124
1125 if (RELOC(prom_memory_limit)) {
1126 if (RELOC(prom_memory_limit) <= RELOC(alloc_bottom)) {
1127 prom_printf("Ignoring mem=%x <= alloc_bottom.\n",
1128 RELOC(prom_memory_limit));
1129 RELOC(prom_memory_limit) = 0;
1130 } else if (RELOC(prom_memory_limit) >= RELOC(ram_top)) {
1131 prom_printf("Ignoring mem=%x >= ram_top.\n",
1132 RELOC(prom_memory_limit));
1133 RELOC(prom_memory_limit) = 0;
1134 } else {
1135 RELOC(ram_top) = RELOC(prom_memory_limit);
1136 RELOC(rmo_top) = min(RELOC(rmo_top), RELOC(prom_memory_limit));
1137 }
1138 }
1139
1140 /*
1141 * Setup our top alloc point, that is top of RMO or top of 1106 * Setup our top alloc point, that is top of RMO or top of
1142 * segment 0 when running non-LPAR. 1107 * segment 0 when running non-LPAR.
1143 * Some RS64 machines have buggy firmware where claims up at 1108 * Some RS64 machines have buggy firmware where claims up at
@@ -1149,9 +1114,9 @@ static void __init prom_init_mem(void)
1149 RELOC(rmo_top) = RELOC(ram_top); 1114 RELOC(rmo_top) = RELOC(ram_top);
1150 RELOC(rmo_top) = min(0x30000000ul, RELOC(rmo_top)); 1115 RELOC(rmo_top) = min(0x30000000ul, RELOC(rmo_top));
1151 RELOC(alloc_top) = RELOC(rmo_top); 1116 RELOC(alloc_top) = RELOC(rmo_top);
1117 RELOC(alloc_top_high) = RELOC(ram_top);
1152 1118
1153 prom_printf("memory layout at init:\n"); 1119 prom_printf("memory layout at init:\n");
1154 prom_printf(" memory_limit : %x (16 MB aligned)\n", RELOC(prom_memory_limit));
1155 prom_printf(" alloc_bottom : %x\n", RELOC(alloc_bottom)); 1120 prom_printf(" alloc_bottom : %x\n", RELOC(alloc_bottom));
1156 prom_printf(" alloc_top : %x\n", RELOC(alloc_top)); 1121 prom_printf(" alloc_top : %x\n", RELOC(alloc_top));
1157 prom_printf(" alloc_top_hi : %x\n", RELOC(alloc_top_high)); 1122 prom_printf(" alloc_top_hi : %x\n", RELOC(alloc_top_high));
@@ -1348,16 +1313,10 @@ static void __init prom_initialize_tce_table(void)
1348 1313
1349 reserve_mem(local_alloc_bottom, local_alloc_top - local_alloc_bottom); 1314 reserve_mem(local_alloc_bottom, local_alloc_top - local_alloc_bottom);
1350 1315
1351 if (RELOC(prom_memory_limit)) { 1316 /* These are only really needed if there is a memory limit in
1352 /* 1317 * effect, but we don't know so export them always. */
1353 * We align the start to a 16MB boundary so we can map 1318 RELOC(prom_tce_alloc_start) = local_alloc_bottom;
1354 * the TCE area using large pages if possible. 1319 RELOC(prom_tce_alloc_end) = local_alloc_top;
1355 * The end should be the top of RAM so no need to align it.
1356 */
1357 RELOC(prom_tce_alloc_start) = _ALIGN_DOWN(local_alloc_bottom,
1358 0x1000000);
1359 RELOC(prom_tce_alloc_end) = local_alloc_top;
1360 }
1361 1320
1362 /* Flag the first invalid entry */ 1321 /* Flag the first invalid entry */
1363 prom_debug("ending prom_initialize_tce_table\n"); 1322 prom_debug("ending prom_initialize_tce_table\n");
@@ -2265,10 +2224,6 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,
2265 /* 2224 /*
2266 * Fill in some infos for use by the kernel later on 2225 * Fill in some infos for use by the kernel later on
2267 */ 2226 */
2268 if (RELOC(prom_memory_limit))
2269 prom_setprop(_prom->chosen, "/chosen", "linux,memory-limit",
2270 &RELOC(prom_memory_limit),
2271 sizeof(prom_memory_limit));
2272#ifdef CONFIG_PPC64 2227#ifdef CONFIG_PPC64
2273 if (RELOC(ppc64_iommu_off)) 2228 if (RELOC(ppc64_iommu_off))
2274 prom_setprop(_prom->chosen, "/chosen", "linux,iommu-off", 2229 prom_setprop(_prom->chosen, "/chosen", "linux,iommu-off",