Patchwork [v3] powerpc/4xx: work around CHIP11 errata in a more PAGE_SIZE-friendly way

login
register
mail settings
Submitter Hollis Blanchard
Date Nov. 25, 2008, 9:53 p.m.
Message ID <1227650039.7434.33.camel@localhost.localdomain>
Download mbox | patch
Permalink /patch/10794/
State Superseded, archived
Headers show

Comments

Hollis Blanchard - Nov. 25, 2008, 9:53 p.m.
On Tue, 2008-11-25 at 11:10 +1100, Michael Ellerman wrote:
> 
> Still, I think it would be better to only set memory_limit when the mem
> size is not a multiple of the PAGE_SIZE - so that memory_limit retains
> it's function as both the value of the limit and a boolean.

OK, how's this?

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).

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Michael Ellerman - Nov. 25, 2008, 11:43 p.m.
On Tue, 2008-11-25 at 15:53 -0600, Hollis Blanchard wrote:
> On Tue, 2008-11-25 at 11:10 +1100, Michael Ellerman wrote:
> > 
> > Still, I think it would be better to only set memory_limit when the mem
> > size is not a multiple of the PAGE_SIZE - so that memory_limit retains
> > it's function as both the value of the limit and a boolean.
> 
> OK, how's this?
> 
> 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).
> 
> Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
> 
> diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
> --- a/arch/powerpc/kernel/prom.c
> +++ b/arch/powerpc/kernel/prom.c
> @@ -1160,6 +1160,8 @@ static inline void __init phyp_dump_rese
>  
>  void __init early_init_devtree(void *params)
>  {
> +	unsigned long limit, memsize;
> +
>  	DBG(" -> early_init_devtree(%p)\n", params);
>  
>  	/* Setup flat device-tree pointer */
> @@ -1200,7 +1202,15 @@ void __init early_init_devtree(void *par
>  	early_reserve_mem();
>  	phyp_dump_reserve_mem();

I was thinking more like the following:

>  
> -	lmb_enforce_memory_limit(memory_limit);
> +	limit = memory_limit;
> +	if (! limit) {
> +		/* 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);
> +

So that we never needlessly run through the enforce code with limit =
memsize. But maybe it's a bit pedantic.

cheers

Patch

diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -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,15 @@  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) {
+		/* Ensure that total memory size is page-aligned, because
+		 * otherwise mark_bootmem() gets upset. */
+		lmb_analyze();
+		limit = lmb_phys_mem_size() & PAGE_MASK;
+	}
+	lmb_enforce_memory_limit(limit);
+
 	lmb_analyze();
 
 	DBG("Phys. mem: %lx\n", lmb_phys_mem_size());