From patchwork Wed Mar 11 16:00:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 45684 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 356B6214BF for ; Wed, 11 Mar 2015 16:00:39 +0000 (UTC) Received: by wghk14 with SMTP id k14sf7320390wgh.3 for ; Wed, 11 Mar 2015 09:00:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=2rNvuMto0l52zIXc7mooaBxeLQX/nwqqhXzk1CHFRHI=; b=I3cyxhvmwek+i2mMvdo+YUhpZQZ3kN6zj0bHb5XHWvrVdN+nyGIst6FiqRBhVqMpKn 3ZGKUMAcobmjnrsR4lyu6wcX5aljk4u9hmgHXKzwPP2mZldsMVhXXcDDKUdBObd7BhSq smg3hKpQ/z2nJmQxgsZgq7pt0wj4/5SeeC1JZ/OSV6ngMtnbkJxiEF2uslsBWJEIzrtk V9M5PCore6vJvNupEZ2VeAw78foNCRb+iiLMchYhgdkMAsyuEgw4T6jWzYglsZQ9vVNq 1aKaBiBLJH9hgIYLd9NlkcgvTpwkE11/rEto7IY2hKlyVVyT/4qouCwzlvKR7FeHd3Wv LEUg== X-Gm-Message-State: ALoCoQlw7hTnPC8gSPC0473hTu2jLK/Obg4flznD+0UkSnf2EkCwcZ1JccjEw0a93cHcLONfiRKL X-Received: by 10.152.8.73 with SMTP id p9mr1243719laa.6.1426089638529; Wed, 11 Mar 2015 09:00:38 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.25.193 with SMTP id e1ls176560lag.80.gmail; Wed, 11 Mar 2015 09:00:38 -0700 (PDT) X-Received: by 10.112.201.231 with SMTP id kd7mr14530845lbc.35.1426089638256; Wed, 11 Mar 2015 09:00:38 -0700 (PDT) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id gk5si2616304lbb.76.2015.03.11.09.00.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Mar 2015 09:00:38 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by labgq15 with SMTP id gq15so9836500lab.4 for ; Wed, 11 Mar 2015 09:00:38 -0700 (PDT) X-Received: by 10.112.204.197 with SMTP id la5mr34866193lbc.29.1426089638168; Wed, 11 Mar 2015 09:00:38 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp2869203lbj; Wed, 11 Mar 2015 09:00:36 -0700 (PDT) X-Received: by 10.70.18.68 with SMTP id u4mr45392196pdd.38.1426089634010; Wed, 11 Mar 2015 09:00:34 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cm5si6042889pdb.228.2015.03.11.09.00.33; Wed, 11 Mar 2015 09:00:34 -0700 (PDT) Received-SPF: none (google.com: devicetree-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752055AbbCKQAc (ORCPT + 5 others); Wed, 11 Mar 2015 12:00:32 -0400 Received: from mail-wi0-f180.google.com ([209.85.212.180]:43884 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751423AbbCKQAb (ORCPT ); Wed, 11 Mar 2015 12:00:31 -0400 Received: by widem10 with SMTP id em10so13013592wid.2 for ; Wed, 11 Mar 2015 09:00:30 -0700 (PDT) X-Received: by 10.194.48.12 with SMTP id h12mr81186761wjn.74.1426089630438; Wed, 11 Mar 2015 09:00:30 -0700 (PDT) Received: from ards-macbook-pro.local ([213.143.60.209]) by mx.google.com with ESMTPSA id l6sm5990041wjx.33.2015.03.11.09.00.27 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 11 Mar 2015 09:00:29 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, robh@kernel.org, mark.rutland@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, linux@arm.linux.org.uk, linuxppc-dev@lists.ozlabs.org, devicetree@vger.kernel.org Cc: Ard Biesheuvel , Benjamin Herrenschmidt , Paul Mackerras Subject: [PATCH v2 1/5] of/fdt: split off FDT self reservation from memreserve processing Date: Wed, 11 Mar 2015 17:00:16 +0100 Message-Id: <1426089620-9459-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1426089620-9459-1-git-send-email-ard.biesheuvel@linaro.org> References: <1426089620-9459-1-git-send-email-ard.biesheuvel@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This splits off the reservation of the memory occupied by the FDT binary itself from the processing of the memory reservations it contains. This is necessary because the physical address of the FDT, which is needed to perform the reservation, may not be known to the FDT driver core, i.e., it may be mapped outside the linear direct mapping, in which case __pa() returns a bogus value. Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Signed-off-by: Ard Biesheuvel --- arch/arm/mm/init.c | 1 + arch/arm64/mm/init.c | 1 + arch/powerpc/kernel/prom.c | 1 + drivers/of/fdt.c | 19 ++++++++++++++----- include/linux/of_fdt.h | 2 ++ 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 1609b022a72f..0b8657c36fe4 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -317,6 +317,7 @@ void __init arm_memblock_init(const struct machine_desc *mdesc) if (mdesc->reserve) mdesc->reserve(); + early_init_fdt_reserve_self(); early_init_fdt_scan_reserved_mem(); /* reserve memory for DMA contiguous allocations */ diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index ae85da6307bb..fa2389b0f7f0 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -170,6 +170,7 @@ void __init arm64_memblock_init(void) memblock_reserve(__virt_to_phys(initrd_start), initrd_end - initrd_start); #endif + early_init_fdt_reserve_self(); early_init_fdt_scan_reserved_mem(); /* 4GB maximum for 32-bit only capable devices */ diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index b8e15c678960..093ccfb384af 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -573,6 +573,7 @@ static void __init early_reserve_mem_dt(void) int len; const __be32 *prop; + early_init_fdt_reserve_self(); early_init_fdt_scan_reserved_mem(); dt_root = of_get_flat_dt_root(); diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 3a896c9aeb74..bbb35cdb06e8 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -561,11 +561,6 @@ void __init early_init_fdt_scan_reserved_mem(void) if (!initial_boot_params) return; - /* Reserve the dtb region */ - early_init_dt_reserve_memory_arch(__pa(initial_boot_params), - fdt_totalsize(initial_boot_params), - 0); - /* Process header /memreserve/ fields */ for (n = 0; ; n++) { fdt_get_mem_rsv(initial_boot_params, n, &base, &size); @@ -579,6 +574,20 @@ void __init early_init_fdt_scan_reserved_mem(void) } /** + * early_init_fdt_reserve_self() - reserve the memory used by the FDT blob + */ +void __init early_init_fdt_reserve_self(void) +{ + if (!initial_boot_params) + return; + + /* Reserve the dtb region */ + early_init_dt_reserve_memory_arch(__pa(initial_boot_params), + fdt_totalsize(initial_boot_params), + 0); +} + +/** * of_scan_flat_dt - scan flattened tree blob and call callback on each. * @it: callback function * @data: context data pointer diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index 0ff360d5b3b3..6ef6b33238d3 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -62,6 +62,7 @@ extern int early_init_dt_scan_chosen(unsigned long node, const char *uname, extern int early_init_dt_scan_memory(unsigned long node, const char *uname, int depth, void *data); extern void early_init_fdt_scan_reserved_mem(void); +extern void early_init_fdt_reserve_self(void); extern void early_init_dt_add_memory_arch(u64 base, u64 size); extern int early_init_dt_reserve_memory_arch(phys_addr_t base, phys_addr_t size, bool no_map); @@ -89,6 +90,7 @@ extern u64 fdt_translate_address(const void *blob, int node_offset); extern void of_fdt_limit_memory(int limit); #else /* CONFIG_OF_FLATTREE */ static inline void early_init_fdt_scan_reserved_mem(void) {} +static inline void early_init_fdt_reserve_self(void) {} static inline const char *of_flat_dt_get_machine_name(void) { return NULL; } static inline void unflatten_device_tree(void) {} static inline void unflatten_and_copy_device_tree(void) {}