From patchwork Wed Mar 26 13:52:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Medve X-Patchwork-Id: 333961 X-Patchwork-Delegate: benh@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 87E74140181 for ; Thu, 27 Mar 2014 01:24:20 +1100 (EST) Received: from tx2outboundpool.messaging.microsoft.com (tx2ehsobe001.messaging.microsoft.com [65.55.88.11]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E63B6140090 for ; Thu, 27 Mar 2014 01:23:48 +1100 (EST) Received: from mail84-tx2-R.bigfish.com (10.9.14.243) by TX2EHSOBE012.bigfish.com (10.9.40.32) with Microsoft SMTP Server id 14.1.225.22; Wed, 26 Mar 2014 14:23:44 +0000 Received: from mail84-tx2 (localhost [127.0.0.1]) by mail84-tx2-R.bigfish.com (Postfix) with ESMTP id 4EF7B42018B; Wed, 26 Mar 2014 14:23:44 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 3 X-BigFish: VS3(zz853kzz1f42h2148h208ch1ee6h1de0h1fdah2073h2146h1202h1e76h2189h1d1ah1d2ah21bch1fc6hzdchz1de098h8275bh1de097hz2dh2a8h839he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh2222h224fh1fb3h1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e23h1fe8h1ff5h2218h2216h226dh22d0h24afh2327h2336h2438h2461h2487h24d7h2516h2545h255eh25cch25f6h2605h268bh1155h) Received: from mail84-tx2 (localhost.localdomain [127.0.0.1]) by mail84-tx2 (MessageSwitch) id 1395843821465490_1050; Wed, 26 Mar 2014 14:23:41 +0000 (UTC) Received: from TX2EHSMHS037.bigfish.com (unknown [10.9.14.243]) by mail84-tx2.bigfish.com (Postfix) with ESMTP id 546582C007A; Wed, 26 Mar 2014 14:23:41 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by TX2EHSMHS037.bigfish.com (10.9.99.137) with Microsoft SMTP Server (TLS) id 14.16.227.3; Wed, 26 Mar 2014 14:23:41 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server (TLS) id 14.3.158.2; Wed, 26 Mar 2014 14:23:41 +0000 Received: from lazy.am.freescale.net (lazy.am.freescale.net [10.81.116.101]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id s2QENYjY025419; Wed, 26 Mar 2014 07:23:39 -0700 From: Emil Medve To: , , Subject: [PATCH] bootmem/powerpc: Unify bootmem initialization Date: Wed, 26 Mar 2014 08:52:14 -0500 Message-ID: <1395841934-5139-1-git-send-email-Emilian.Medve@Freescale.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% X-FOPE-CONNECTOR: Id%0$Dn%FREESCALE.MAIL.ONMICROSOFT.COM$RO%1$TLS%0$FQDN%$TlsDn% Cc: Emil Medve X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Unify the low/highmem code path from do_init_bootmem() by using (the) lowmem related variables/parameters even when the low/highmem split is not needed (64-bit) or configured. In such cases the "lowmem" variables/parameters continue to observe the definition by referring to memory directly mapped by the kernel Signed-off-by: Emil Medve --- arch/powerpc/mm/mem.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 32202c9..807a950 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -188,27 +188,31 @@ EXPORT_SYMBOL_GPL(walk_system_ram_range); void __init do_init_bootmem(void) { unsigned long start, bootmap_pages; - unsigned long total_pages; struct memblock_region *reg; int boot_mapsize; + phys_addr_t _total_lowmem; + phys_addr_t _lowmem_end_addr; - max_low_pfn = max_pfn = memblock_end_of_DRAM() >> PAGE_SHIFT; - total_pages = (memblock_end_of_DRAM() - memstart_addr) >> PAGE_SHIFT; -#ifdef CONFIG_HIGHMEM - total_pages = total_lowmem >> PAGE_SHIFT; - max_low_pfn = lowmem_end_addr >> PAGE_SHIFT; +#ifndef CONFIG_HIGHMEM + _lowmem_end_addr = memblock_end_of_DRAM(); +#else + _lowmem_end_addr = lowmem_end_addr; #endif + _total_lowmem = _lowmem_end_addr - memstart_addr; + + max_pfn = memblock_end_of_DRAM() >> PAGE_SHIFT; + max_low_pfn = _lowmem_end_addr >> PAGE_SHIFT; + min_low_pfn = MEMORY_START >> PAGE_SHIFT; /* * Find an area to use for the bootmem bitmap. Calculate the size of * bitmap required as (Total Memory) / PAGE_SIZE / BITS_PER_BYTE. * Add 1 additional page in case the address isn't page-aligned. */ - bootmap_pages = bootmem_bootmap_pages(total_pages); + bootmap_pages = bootmem_bootmap_pages(_total_lowmem >> PAGE_SHIFT); start = memblock_alloc(bootmap_pages << PAGE_SHIFT, PAGE_SIZE); - min_low_pfn = MEMORY_START >> PAGE_SHIFT; boot_mapsize = init_bootmem_node(NODE_DATA(0), start >> PAGE_SHIFT, min_low_pfn, max_low_pfn); /* Place all memblock_regions in the same node and merge contiguous @@ -219,26 +223,18 @@ void __init do_init_bootmem(void) /* Add all physical memory to the bootmem map, mark each area * present. */ -#ifdef CONFIG_HIGHMEM - free_bootmem_with_active_regions(0, lowmem_end_addr >> PAGE_SHIFT); + free_bootmem_with_active_regions(0, max_low_pfn); /* reserve the sections we're already using */ for_each_memblock(reserved, reg) { - unsigned long top = reg->base + reg->size - 1; - if (top < lowmem_end_addr) + if (reg->base + reg->size - 1 < _lowmem_end_addr) reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT); - else if (reg->base < lowmem_end_addr) { - unsigned long trunc_size = lowmem_end_addr - reg->base; + else if (reg->base < _lowmem_end_addr) { + unsigned long trunc_size = _lowmem_end_addr - reg->base; reserve_bootmem(reg->base, trunc_size, BOOTMEM_DEFAULT); } } -#else - free_bootmem_with_active_regions(0, max_pfn); - /* reserve the sections we're already using */ - for_each_memblock(reserved, reg) - reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT); -#endif /* XXX need to clip this if using highmem? */ sparse_memory_present_with_active_regions(0);