From patchwork Mon Nov 3 19:55:21 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hollis Blanchard X-Patchwork-Id: 6960 X-Patchwork-Delegate: jwboyer@gmail.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 55369DDF0A for ; Tue, 4 Nov 2008 06:55:55 +1100 (EST) X-Original-To: linuxppc-dev@ozlabs.org Delivered-To: linuxppc-dev@ozlabs.org Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "e36.co.us.ibm.com", Issuer "Equifax" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id B8742DDE00 for ; Tue, 4 Nov 2008 06:55:37 +1100 (EST) Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e36.co.us.ibm.com (8.13.1/8.13.1) with ESMTP id mA3Jt3mn001889 for ; Mon, 3 Nov 2008 12:55:03 -0700 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id mA3JtP5n094554 for ; Mon, 3 Nov 2008 12:55:29 -0700 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id mA3JssPm015842 for ; Mon, 3 Nov 2008 12:54:55 -0700 Received: from [9.53.41.42] (slate.austin.ibm.com [9.53.41.42]) by d03av02.boulder.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id mA3JsrkT015674; Mon, 3 Nov 2008 12:54:53 -0700 Subject: Re: [PATCH 1/2] powerpc: add 16K/64K pages support for the 44x PPC32 architectures. From: Hollis Blanchard To: benh@kernel.crashing.org In-Reply-To: <1225673034.8004.239.camel@pasglop> References: <1224123753-20907-1-git-send-email-yanok@emcraft.com> <1224123753-20907-2-git-send-email-yanok@emcraft.com> <48FF3889.2030304@linux.vnet.ibm.com> <20081101113018.GA13646@zod.rchland.ibm.com> <1225576502.8004.222.camel@pasglop> <20081102134153.GA1029@zod.rchland.ibm.com> <1225661596.8004.226.camel@pasglop> <20081102193307.32d17e62@zod.rchland.ibm.com> <1225673034.8004.239.camel@pasglop> Organization: IBM Linux Technology Center Date: Mon, 03 Nov 2008 13:55:21 -0600 Message-Id: <1225742121.24019.9.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 (2.22.3.1-1.fc9) Cc: dzu@denx.de, Ilya Yanok , linuxppc-dev@ozlabs.org, pvr@emcraft.com, Wolfgang Denk X-BeenThere: linuxppc-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org On Mon, 2008-11-03 at 11:43 +1100, Benjamin Herrenschmidt wrote: > > Cropping the size of the memory node. That was simplest to do from the > > cuboot wrapper at the time. If marking it reserved via a reserve map > > is more elegant and correct, we could do that. > > > > But I will still like to know what about the other way is hairy please. > > I don't like it :-) Bad feeling ... don't like having a memory > node entry that isn't aligned to some large power of two typically. More specifically, mm/bootmem.c seems to be making the implicit assumption that memory size is an even multiple of PAGE_SIZE. With 4K pages, 0xffff000 bytes of RAM fits; with 64K pages it does not. Using the device tree reserve map stuff does indeed seem to solve the problem. However, I really don't understand the layering in arch/powerpc/boot at all, so I'll just put this patch out here and people can play with wrappers and prototypes all they want: powerpc/4xx: work around CHIP11 errata in a more PAGE_SIZE-friendly way The current CHIP11 errata truncates the device tree memory node, and assumes a 4K page size. This breaks kernels with non-4K PAGE_SIZE. Instead, use a device tree memory reservation to reserve only the 256 bytes actually affected by the errata, leaving the total memory size unaltered. Signed-off-by: Hollis Blanchard diff --git a/arch/powerpc/boot/4xx.c b/arch/powerpc/boot/4xx.c --- a/arch/powerpc/boot/4xx.c +++ b/arch/powerpc/boot/4xx.c @@ -21,7 +21,7 @@ #include "reg.h" #include "dcr.h" -static unsigned long chip_11_errata(unsigned long memsize) +static void chip_11_errata(unsigned long memsize) { unsigned long pvr; @@ -31,13 +31,11 @@ static unsigned long chip_11_errata(unsi case 0x40000850: case 0x400008d0: case 0x200008d0: - memsize -= 4096; + fdt_reserve_mem(memsize - 256, 256); break; default: break; } - - return memsize; } /* Read the 4xx SDRAM controller to get size of system memory. */ @@ -53,7 +51,7 @@ void ibm4xx_sdram_fixup_memsize(void) memsize += SDRAM_CONFIG_BANK_SIZE(bank_config); } - memsize = chip_11_errata(memsize); + chip_11_errata(memsize); dt_fixup_memory(0, memsize); } @@ -219,7 +217,7 @@ void ibm4xx_denali_fixup_memsize(void) bank = 4; /* 4 banks */ memsize = cs * (1 << (col+row)) * bank * dpath; - memsize = chip_11_errata(memsize); + chip_11_errata(memsize); dt_fixup_memory(0, memsize); } diff --git a/arch/powerpc/boot/libfdt-wrapper.c b/arch/powerpc/boot/libfdt-wrapper.c --- a/arch/powerpc/boot/libfdt-wrapper.c +++ b/arch/powerpc/boot/libfdt-wrapper.c @@ -167,6 +167,11 @@ static unsigned long fdt_wrapper_finaliz return (unsigned long)fdt; } +int fdt_reserve_mem(unsigned long addr, unsigned long bytes) +{ + return fdt_add_mem_rsv(fdt, addr, bytes); +} + void fdt_init(void *blob) { int err; diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h --- a/arch/powerpc/boot/ops.h +++ b/arch/powerpc/boot/ops.h @@ -83,6 +83,7 @@ extern struct loader_info loader_info; void start(void); void fdt_init(void *blob); +int fdt_reserve_mem(unsigned long addr, unsigned long bytes); int serial_console_init(void); int ns16550_console_init(void *devp, struct serial_console_data *scdp); int mpsc_console_init(void *devp, struct serial_console_data *scdp);