From patchwork Mon May 11 06:41:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 48200 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 203322121F for ; Mon, 11 May 2015 06:44:52 +0000 (UTC) Received: by lbbqq2 with SMTP id qq2sf36054003lbb.0 for ; Sun, 10 May 2015 23:44:50 -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=zOJkT6UdKmTnxliJdmFawqLYhjsk04lwOmFVJZELqjU=; b=aos7NWJXWXfCFN77ZnMVWE5jpemAcRUj8wN9CQIsHonp97xqSLGERnOLIzEWk2wTMR kX46ClPj8sy9Po6YIi9YRVU0VaDRuARbMJq6IAlylVZbn+siPRuzHEPh6fVM4ydSMMuh RPk4dCLqWLFLLIeqvgbY21sLO6XA1riqpiz+l0Htbzk0ijKDmA+3Hlhwl6A2kGjvTpsA 6eOGepO46ooS80EH/WLn6fZ20sS5N34oNVrrGb4jsRBBxofnBCv6QABeZnIGDNM1kuu0 74hGmmC/GL16haQfIW/F4exVBto5hYk36QgT65QRWILDSKQbO9asL46l/lK+66ZRG/sE 6nrA== X-Gm-Message-State: ALoCoQlPqkE2/fFZswesLmqo2CUjX8wYw1ia4pakWAFTXY9hTPp2Z776/5FAcIliSZJDc6MdJcW+ X-Received: by 10.152.116.115 with SMTP id jv19mr6603691lab.9.1431326690577; Sun, 10 May 2015 23:44:50 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.30.37 with SMTP id p5ls602588lah.9.gmail; Sun, 10 May 2015 23:44:50 -0700 (PDT) X-Received: by 10.112.170.7 with SMTP id ai7mr6798759lbc.85.1431326690435; Sun, 10 May 2015 23:44:50 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id y1si7823808lag.66.2015.05.10.23.44.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 May 2015 23:44:50 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by lbbuc2 with SMTP id uc2so87012244lbb.2 for ; Sun, 10 May 2015 23:44:50 -0700 (PDT) X-Received: by 10.112.204.104 with SMTP id kx8mr6855848lbc.72.1431326690335; Sun, 10 May 2015 23:44:50 -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.108.230 with SMTP id hn6csp1334645lbb; Sun, 10 May 2015 23:44:48 -0700 (PDT) X-Received: by 10.66.229.9 with SMTP id sm9mr16734426pac.1.1431326686904; Sun, 10 May 2015 23:44:46 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id lj8si16747704pbc.11.2015.05.10.23.44.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 May 2015 23:44:46 -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 1YrhQN-0007MT-Q5; Mon, 11 May 2015 06:42:47 +0000 Received: from mail-wg0-f53.google.com ([74.125.82.53]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YrhQ8-0007DE-IB for linux-arm-kernel@lists.infradead.org; Mon, 11 May 2015 06:42:34 +0000 Received: by wgbhc8 with SMTP id hc8so18118562wgb.2 for ; Sun, 10 May 2015 23:42:09 -0700 (PDT) X-Received: by 10.180.89.231 with SMTP id br7mr17795251wib.60.1431326529601; Sun, 10 May 2015 23:42:09 -0700 (PDT) Received: from localhost.localdomain (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by mx.google.com with ESMTPSA id wr2sm21173009wjb.45.2015.05.10.23.42.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 10 May 2015 23:42:08 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, grant.likely@linaro.org, leif.lindholm@linaro.org, roy.franz@linaro.org, catalin.marinas@arm.com, mark.rutland@arm.com, matt.fleming@intel.com Subject: [PATCH 1/8] of/fdt: split off FDT self reservation from memreserve processing Date: Mon, 11 May 2015 08:41:53 +0200 Message-Id: <1431326520-17331-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1431326520-17331-1-git-send-email-ard.biesheuvel@linaro.org> References: <1431326520-17331-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150510_234232_809273_712878A7 X-CRM114-Status: GOOD ( 15.21 ) 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.53 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [74.125.82.53 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 , Russell King , Ganapatrao.Kulkarni@caviumnetworks.com, 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.176 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 Acked-by: Mark Rutland 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 be92fa0f2f35..8a63b4cdc0f2 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -268,6 +268,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 597831bdddf3..89a05f467ffb 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 308c5e15676b..51ea36f79307 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 cde35c5d0191..f2dd23a32267 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -580,11 +580,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); @@ -598,6 +593,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 587ee507965d..fd627a58068f 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -64,6 +64,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); @@ -91,6 +92,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) {}