Skip to contentSkip to conversation

ppc: force memory size to be a multiple of PAGE_SIZE

PATCH In review Hollis Blanchard 2 participants 2 messages Nov 26, 2008 – Dec 1, 2008 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 ppc: force memory size to be a multiple of PAGE_SIZE

Ensure that total memory size is page-aligned, because otherwise mark_bootmem() gets upset.

This error case was triggered by using 64 KiB pages in the kernel while arch/powerpc/boot/4xx.c arbitrarily reduced the amount of memory by 4096 (to work around a chip bug that affects the last 256 bytes of physical memory).

---
Changes from v3:
- No need to call lmb_enforce_memory_limit() with limit=lmb_phys_mem_size().

arch/powerpc/kernel/prom.c +15 -1
@@ -1160,6 +1160,8 @@ static inline void __init phyp_dump_rese
 
 void __init early_init_devtree(void *params)
 {
+	unsigned long limit;
+
 	DBG(" -> early_init_devtree(%p)\n", params);
 
 	/* Setup flat device-tree pointer */
@@ -1200,7 +1202,19 @@ void __init early_init_devtree(void *par
 	early_reserve_mem();
 	phyp_dump_reserve_mem();
 
-	lmb_enforce_memory_limit(memory_limit);
+	limit = memory_limit;
+	if (! limit) {
+		unsigned long memsize;
+
+		/* Ensure that total memory size is page-aligned, because
+		 * otherwise mark_bootmem() gets upset. */
+		lmb_analyze();
+		memsize = lmb_phys_mem_size();
+		if ((memsize & PAGE_MASK) != memsize)
+			limit = memsize & PAGE_MASK;
+	}
+	lmb_enforce_memory_limit(limit);
+
 	lmb_analyze();
 
 	DBG("Phys. mem: %lx\n", lmb_phys_mem_size());
#1 lore raw
Quoted 35 lines · Hollis Blanchard

Ensure that total memory size is page-aligned, because otherwise mark_bootmem() gets upset.

This error case was triggered by using 64 KiB pages in the kernel while arch/powerpc/boot/4xx.c arbitrarily reduced the amount of memory by 4096 (to work around a chip bug that affects the last 256 bytes of physical memory).

---
Changes from v3:
- No need to call lmb_enforce_memory_limit() with limit=lmb_phys_mem_size().

arch/powerpc/kernel/prom.c +8 -1
@@ -1160,6 +1160,8 @@ static inline void __init phyp_dump_rese
 
 void __init early_init_devtree(void *params)
 {
+       unsigned long limit;
+
       DBG(" -> early_init_devtree(%p)\n", params);
 
       /* Setup flat device-tree pointer */
@@ -1200,7 +1202,19 @@ void __init early_init_devtree(void *par
       early_reserve_mem();
       phyp_dump_reserve_mem();
 
-       lmb_enforce_memory_limit(memory_limit);
+       limit = memory_limit;
+       if (! limit) {
+               unsigned long memsize;
+
+               /* Ensure that total memory size is page-aligned, because
+                * otherwise mark_bootmem() gets upset. */

arch/powerpc/kernel/prom.c void __init early_init_devtree(void *par · line 1220

Quoted 10 lines
arch/powerpc/kernel/prom.c +7 -0
+               lmb_analyze();
+               memsize = lmb_phys_mem_size();
+               if ((memsize & PAGE_MASK) != memsize)
+                       limit = memsize & PAGE_MASK;
+       }
+       lmb_enforce_memory_limit(limit);
+
       lmb_analyze();
 
       DBG("Phys. mem: %lx\n", lmb_phys_mem_size());

Paul or Ben: since there have been no further comments on this, would you queue it up for 2.6.29? Thanks.

-Hollis