From patchwork Fri Jul 9 05:03:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Blanchard X-Patchwork-Id: 58333 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id B1F961007EB for ; Fri, 9 Jul 2010 15:11:33 +1000 (EST) Received: by ozlabs.org (Postfix, from userid 1010) id 42AE0B6F19; Fri, 9 Jul 2010 15:11:32 +1000 (EST) Message-Id: <20100709050342.259074546@samba.org> User-Agent: quilt/0.48-1 Date: Fri, 09 Jul 2010 15:03:40 +1000 From: Anton Blanchard To: yaboot-devel@lists.ozlabs.org Subject: [patch 10/14] Add prom_claim_chunk_top References: <20100709050330.507659708@samba.org> Content-Disposition: inline; filename=prom_claim_chunk_top X-BeenThere: yaboot-devel@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Technical and development discussion regarding yaboot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: yaboot-devel-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Errors-To: yaboot-devel-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org We want temporary allocations to be taken from the top of our address space so the kernel and initrd can be loaded as low as possible. The very early kernel code uses the top of the initrd as the low watermark for memory allocations so the lower this is the better. We currently see a number of fails where a large initrd causes us to run out of space in a 128MB RMO region. Allocating the temporary areas up high and therefore the initrd lower fixes it. Signed-off-by: Anton Blanchard Index: yaboot/second/prom.c =================================================================== --- yaboot.orig/second/prom.c 2010-07-09 14:36:47.000000000 +1000 +++ yaboot/second/prom.c 2010-07-09 14:39:19.000000000 +1000 @@ -599,6 +599,23 @@ prom_claim_chunk(void *virt, unsigned in return((void*)-1); } +/* Start from top of memory and work down to get the needed space */ +void * +prom_claim_chunk_top(unsigned int size, unsigned int align) +{ + void *found, *addr; + for(addr=(void*)PROM_CLAIM_MAX_ADDR; addr >= (void *)size; + addr-=(0x100000/sizeof(addr))) { + found = call_prom("claim", 3, 1, addr, size, 0); + if (found != (void *)-1) { + prom_debug("claim of 0x%x at 0x%x returned 0x%x\n", size, (int)addr, (int)found); + return(found); + } + } + prom_printf("ERROR: claim of 0x%x in range 0x0-0x%x failed\n", size, PROM_CLAIM_MAX_ADDR); + return((void*)-1); +} + void * prom_claim (void *virt, unsigned int size, unsigned int align) { Index: yaboot/include/prom.h =================================================================== --- yaboot.orig/include/prom.h 2010-07-09 14:36:47.000000000 +1000 +++ yaboot/include/prom.h 2010-07-09 14:39:09.000000000 +1000 @@ -91,6 +91,7 @@ int prom_set_color(prom_handle device, i /* memory */ void *prom_claim_chunk(void *virt, unsigned int size, unsigned int align); +void *prom_claim_chunk_top(unsigned int size, unsigned int align); void *prom_claim (void *virt, unsigned int size, unsigned int align); void prom_release(void *virt, unsigned int size); void prom_map (void *phys, void *virt, int size);