From patchwork Wed Mar 18 17:05:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 45976 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 30DD52153C for ; Wed, 18 Mar 2015 17:08:55 +0000 (UTC) Received: by wghk14 with SMTP id k14sf8402700wgh.3 for ; Wed, 18 Mar 2015 10:08:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=avkTJ+KuCIsnawoMQCYTRRmauOtaMBU3TKJVt9Y7cIw=; b=juvH8J2M8WxHiphgyuNcAUVAFl5uiS6c/G+DEsuWbA/Ul/YHvdXihZINwNf4AR7UCM jtUzWqMB1He8S012jb0HocninWnoqmeZj3z0rMwtfqFOI0LZU20/Ge4rgKA4FSVW5v6e qMY+zGXpbJ9TwEjZBGm5bdbolGMVrvj+hPiKGF9tYUmyqBjBUbaa2TiKeqLnoHvnjxOr VwShqRyybqrSirB1eNh+b3JQyDKgpEEb6G3tJhARPiJlSRB0jL+oqqS3BqLhraMlyuQB yI3NRVLJqk/wfHRbIOrmusdjAMGj2ICJsG8EpkFWAAsBOHeFMgQuz+1TFcl2/RqPp/Bi fBnA== X-Gm-Message-State: ALoCoQkRyDi9a6V0wS0F56bfhaZMMGms/U7CJpzi+dFctwJpes+i5Hb2UA2yUv//WzqR/596ULBl X-Received: by 10.180.90.175 with SMTP id bx15mr967863wib.3.1426698534541; Wed, 18 Mar 2015 10:08:54 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.237 with SMTP id r13ls187775lal.74.gmail; Wed, 18 Mar 2015 10:08:54 -0700 (PDT) X-Received: by 10.112.210.230 with SMTP id mx6mr34344380lbc.64.1426698534241; Wed, 18 Mar 2015 10:08:54 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id cv3si13342071lbb.138.2015.03.18.10.08.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Mar 2015 10:08:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by lbcgn8 with SMTP id gn8so34557158lbc.2 for ; Wed, 18 Mar 2015 10:08:54 -0700 (PDT) X-Received: by 10.152.121.33 with SMTP id lh1mr65380535lab.86.1426698534100; Wed, 18 Mar 2015 10:08:54 -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 h5csp1286980lbj; Wed, 18 Mar 2015 10:08:53 -0700 (PDT) X-Received: by 10.70.125.162 with SMTP id mr2mr153212167pdb.21.1426698532056; Wed, 18 Mar 2015 10:08:52 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id qz7si37190490pab.128.2015.03.18.10.08.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Mar 2015 10:08:52 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; 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 1YYHQZ-0000FK-5Z; Wed, 18 Mar 2015 17:06:43 +0000 Received: from mail-we0-f174.google.com ([74.125.82.174]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YYHPh-0008DO-Dh for linux-arm-kernel@lists.infradead.org; Wed, 18 Mar 2015 17:05:50 +0000 Received: by wetk59 with SMTP id k59so37428486wet.3 for ; Wed, 18 Mar 2015 10:05:27 -0700 (PDT) X-Received: by 10.194.94.164 with SMTP id dd4mr146908809wjb.56.1426698327283; Wed, 18 Mar 2015 10:05:27 -0700 (PDT) Received: from ards-macbook-pro.local ([84.78.25.113]) by mx.google.com with ESMTPSA id dc9sm3972217wib.9.2015.03.18.10.05.24 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 18 Mar 2015 10:05:26 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk, will.deacon@arm.com, mark.rutland@arm.com, catalin.marinas@arm.com, robh@kernel.org Subject: [PATCH v3 1/5] of/fdt: split off FDT self reservation from memreserve processing Date: Wed, 18 Mar 2015 18:05:04 +0100 Message-Id: <1426698308-726-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1426698308-726-1-git-send-email-ard.biesheuvel@linaro.org> References: <1426698308-726-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150318_100549_658772_E84CBC60 X-CRM114-Status: GOOD ( 15.35 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.174 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [74.125.82.174 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Benjamin Herrenschmidt , Paul Mackerras , Ard Biesheuvel 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.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.217.178 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 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: Russell King Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Acked-by: Rob Herring 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) {}