From patchwork Sun Aug 4 00:45:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hao X-Patchwork-Id: 264445 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 8AB532C00AA for ; Sun, 4 Aug 2013 10:46:17 +1000 (EST) Received: from mail-pd0-x231.google.com (mail-pd0-x231.google.com [IPv6:2607:f8b0:400e:c02::231]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id B01182C0084 for ; Sun, 4 Aug 2013 10:45:51 +1000 (EST) Received: by mail-pd0-f177.google.com with SMTP id u10so1947877pdi.22 for ; Sat, 03 Aug 2013 17:45:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=mlHG6zkcbUEvtCbpnDkmvDBwAoXNzdRvlJ8p5goMrYw=; b=qFtLPf7JD239gi6/+PAFkNm5lzEldZKm085OZAAP/9nkF3lEKnx9hv8qimkbc+mDxP C4E4is4ZnViDoRbuAmn2BlXa4XtBohL4Bc8tEE0lN7vAAyXZYUhbiLQbAbJd/0whpWLI lcHWyl5uP15IafTts+euwvu5N0OAkdeS9iY7KoTT1IPVbQjdGYp/E8ykAlqTA8ed9Uby LYViI6X8v5zvZfPTS1dGGCy4qRiiaXcoiN2xxbtFYX0CkViXITNcY7Tg1Lkz9u8SQsNu 908h7xRdpzQM5z9KgOJDHGs/dOhQjbY2adLDTNMYsTciTH6/8s0SZ1VNwiQYcCNGxdqO 4aRg== X-Received: by 10.68.203.105 with SMTP id kp9mr11084173pbc.78.1375577149298; Sat, 03 Aug 2013 17:45:49 -0700 (PDT) Received: from pek-khao-d1.corp.ad.wrs.com ([1.202.252.122]) by mx.google.com with ESMTPSA id om2sm18585788pbc.30.2013.08.03.17.45.39 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 03 Aug 2013 17:45:48 -0700 (PDT) Date: Sun, 4 Aug 2013 08:45:32 +0800 From: Kevin Hao To: Scott Wood Subject: Re: [PATCH v2 6/8] powerpc: introduce early_get_first_memblock_info Message-ID: <20130804004531.GD19141@pek-khao-d1.corp.ad.wrs.com> References: <1372942454-25191-7-git-send-email-haokexin@gmail.com> <1374884281.30721.40@snotra> MIME-Version: 1.0 In-Reply-To: <1374884281.30721.40@snotra> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: linuxppc X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 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" On Fri, Jul 26, 2013 at 07:18:01PM -0500, Scott Wood wrote: > >+ * This function run before early_init_devtree, so we have to init > >+ * initial_boot_params. Since early_init_dt_scan_memory_ppc will be > >+ * executed again in early_init_devtree, we have to reinitialize the > >+ * memblock data before return. > >+ */ > >+void __init early_get_first_memblock_info(void *params, > >phys_addr_t *size) > >+{ > >+ /* Setup flat device-tree pointer */ > >+ initial_boot_params = params; > >+ > >+ /* Scan memory nodes and rebuild MEMBLOCKs */ > >+ of_scan_flat_dt(early_init_dt_scan_root, NULL); > >+ of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL); > >+ > >+ if (size) > >+ *size = first_memblock_size; > >+ > >+ /* Undo what early_init_dt_scan_memory_ppc does to memblock */ > >+ memblock_reinit(); > >+} > >+#endif > > Wouldn't it be simpler to set a flag so that > early_init_dt_add_memory_arch() doesn't mess with memblocks on the > first pass? Do you mean something like this? Thanks, Kevin > > -Scott diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index 9a69d2d..e861394 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -523,6 +523,10 @@ static int __init early_init_dt_scan_memory_ppc(unsigned long node, void __init early_init_dt_add_memory_arch(u64 base, u64 size) { +#if defined(CONFIG_RELOCATABLE) && defined(CONFIG_FSL_BOOKE) + static int first_time = 1; +#endif + #ifdef CONFIG_PPC64 if (iommu_is_off) { if (base >= 0x80000000ul) @@ -541,6 +545,13 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size) } /* Add the chunk to the MEMBLOCK list */ + +#if defined(CONFIG_RELOCATABLE) && defined(CONFIG_FSL_BOOKE) + if (first_time) { + first_time = 0; + return; + } +#endif memblock_add(base, size); }