From patchwork Wed Oct 15 17:18:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 5086331 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E5D319F2BA for ; Wed, 15 Oct 2014 17:22:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BEB2220138 for ; Wed, 15 Oct 2014 17:22:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D845D2012E for ; Wed, 15 Oct 2014 17:22:17 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XeSE4-0004RO-KR; Wed, 15 Oct 2014 17:19:04 +0000 Received: from arroyo.ext.ti.com ([192.94.94.40]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XeSDz-0004QC-Kb for linux-arm-kernel@lists.infradead.org; Wed, 15 Oct 2014 17:19:00 +0000 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s9FHIQqs008540; Wed, 15 Oct 2014 12:18:26 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9FHIPLa024764; Wed, 15 Oct 2014 12:18:25 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.174.1; Wed, 15 Oct 2014 12:18:25 -0500 Received: from [192.168.192.164] (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9FHINnk021189; Wed, 15 Oct 2014 12:18:24 -0500 Message-ID: <543EAC5A.6050209@ti.com> Date: Wed, 15 Oct 2014 20:18:18 +0300 From: Grygorii Strashko User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 MIME-Version: 1.0 To: linux-arm , "linux@arm.linux.org.uk" , , Grant Likely Subject: ARM: issue with memory reservation from DT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141015_101859_767761_9C27ED6D X-CRM114-Status: UNSURE ( 9.86 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -5.0 (-----) Cc: Rob Herring , "Karicheri, Muralidharan" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi All, I did some experiments with memory reservation from DT and got boot failure. Input data: - Platform Keystone 2 K2HK - LPAE enabled - RAM 1G: memory { reg = <0x8 0x00000000 0x0 0x40000000>; }; - memory reservation 512M: reserved-memory { #address-cells = <2>; #size-cells = <2>; ranges; dspsmem: dspsmem@20000000 { reg = <0x8 0x20000000 0x0 0x20000000>; no-map; }; }; So, total memory available for Kernel should be 512M, below is memory state for the case when memory is reserved from u-boot: [ 0.000000] Memory: 486200K/524288K available (5085K kernel code, 265K rwdata, 1776K rodata, 296K init, 178K bss, 38088K reserved, 0K highmem) [ 0.000000] Virtual kernel memory layout: [ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB) [ 0.000000] fixmap : 0xffc00000 - 0xffe00000 (2048 kB) [ 0.000000] vmalloc : 0xe0800000 - 0xff000000 ( 488 MB) [ 0.000000] lowmem : 0xc0000000 - 0xe0000000 ( 512 MB) [ 0.000000] pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB) [ 0.000000] modules : 0xbf000000 - 0xbfe00000 ( 14 MB) [ 0.000000] .text : 0xc0008000 - 0xc06bb8a4 (6863 kB) [ 0.000000] .init : 0xc06bc000 - 0xc0706000 ( 296 kB) [ 0.000000] .data : 0xc0706000 - 0xc07485fc ( 266 kB) [ 0.000000] .bss : 0xc07485fc - 0xc07751e0 ( 179 kB) Why: - I'm trying to reserve memory from kernel instead of u-boot. Fast ;( investigation results: 1) The issue happens only if no-map; is used. In this case FDT code will call memblock_remove() instead of memblock_reserve(). 2) ARM limits are set wrongly from sanity_check_meminfo(): [ 0.000000] ======= memblock_limit=0x000000082f800000 arm_lowmem_limit=0x000000082f800000 vmalloc_limit=ef800000 high_memory=0x000000082f800000 instead of [ 0.000000] ======= memblock_limit=0x0000000820000000 arm_lowmem_limit=0x0000000820000000 vmalloc_limit=e0000000 high_memory=0x000000082f800000 3) If I apply below change - I can boot: ^^ not sure if it totally safe, because dma_contiguous_reserve(arm_dma_limit); is called from inside arm_memblock_init() and it does bootmem allocations. Sort Summary: It looks like all static memory reservation and memory stealing's (calling of memblock_remove()) have to be done before any other operations and before calculating ARM memory limits. Thank you for any comments. Regards, -grygorii diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index c031063..85ad92b 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -917,8 +917,8 @@ void __init setup_arch(char **cmdline_p) early_paging_init(mdesc, lookup_processor_type(read_cpuid_id())); setup_dma_zone(mdesc); - sanity_check_meminfo(); arm_memblock_init(mdesc); + sanity_check_meminfo(); paging_init(mdesc); request_standard_resources(mdesc);