From patchwork Mon Jun 1 11:40:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 49294 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A04BF218FC for ; Mon, 1 Jun 2015 11:42:52 +0000 (UTC) Received: by wgme6 with SMTP id e6sf32598782wgm.3 for ; Mon, 01 Jun 2015 04:42:51 -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=8LIzjbKI4wIrqKFlh0n/uiShU2o9Bx1ffj+MIhQ6aBg=; b=eM1377fA82BiJKNQqVVu4qJkE51vHrC/uWyxMaYwMxR+KqE1eMNrXnPR4KuSSXhB06 aEiAHqRE2tlkM6TWoD3NlFJTsHjo7qmv++kGH5+HyYDLXkTJ1VDRVfLxMFr/Yp/48XqI Qv281PwOi6muR5YnOw9pPOqf1QaDzjqq0T+bHFJTVUX3lt5eVroBCUn9kwUpM/8cNs77 Hec732vtkCyBZDd/QjPMbWeQZYNpMmZfGrsFXazZ3owG0Sq5CZE29tWtfXi0IpPb6940 5SMmV2NbFJgkPSaxb+c0LOLKLYgv1/c5KsyKmZbKkaJyTBBjZ03Nrhh674WpL6jeVh70 cBzA== X-Gm-Message-State: ALoCoQkTrnS6PSnuUHqD1UFAu7TsIlZqyv9m2md/Hrsu2jsBzlEKBh1Vn0/kzo89P2DDwc0CMqeK X-Received: by 10.194.58.164 with SMTP id s4mr4089221wjq.3.1433158971717; Mon, 01 Jun 2015 04:42:51 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.162 with SMTP id g2ls625551lae.80.gmail; Mon, 01 Jun 2015 04:42:51 -0700 (PDT) X-Received: by 10.112.210.9 with SMTP id mq9mr7844539lbc.4.1433158971549; Mon, 01 Jun 2015 04:42:51 -0700 (PDT) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id e1si12115136lam.23.2015.06.01.04.42.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jun 2015 04:42:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by lbcmx3 with SMTP id mx3so82438419lbc.1 for ; Mon, 01 Jun 2015 04:42:51 -0700 (PDT) X-Received: by 10.112.204.6 with SMTP id ku6mr20626051lbc.73.1433158971099; Mon, 01 Jun 2015 04:42:51 -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 hn6csp2250244lbb; Mon, 1 Jun 2015 04:42:49 -0700 (PDT) X-Received: by 10.70.42.134 with SMTP id o6mr9428337pdl.11.1433158969237; Mon, 01 Jun 2015 04:42:49 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id xa1si21231753pac.47.2015.06.01.04.42.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jun 2015 04:42:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) 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 1YzO5r-0007pd-1Z; Mon, 01 Jun 2015 11:41:23 +0000 Received: from mail-wg0-f46.google.com ([74.125.82.46]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YzO5e-0007jx-JS for linux-arm-kernel@lists.infradead.org; Mon, 01 Jun 2015 11:41:12 +0000 Received: by wgme6 with SMTP id e6so111670542wgm.2 for ; Mon, 01 Jun 2015 04:40:47 -0700 (PDT) X-Received: by 10.180.88.72 with SMTP id be8mr20306167wib.42.1433158847827; Mon, 01 Jun 2015 04:40:47 -0700 (PDT) Received: from localhost.localdomain ([31.157.58.113]) by mx.google.com with ESMTPSA id l6sm21505253wjz.4.2015.06.01.04.40.45 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Jun 2015 04:40:46 -0700 (PDT) From: Ard Biesheuvel To: catalin.marinas@arm.com, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH for-v4.2 1/4] of/fdt: split off FDT self reservation from memreserve processing Date: Mon, 1 Jun 2015 13:40:31 +0200 Message-Id: <1433158834-25238-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1433158834-25238-1-git-send-email-ard.biesheuvel@linaro.org> References: <1433158834-25238-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150601_044110_828256_C0BA8F33 X-CRM114-Status: GOOD ( 16.29 ) 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.46 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [74.125.82.46 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Russell King , Ard Biesheuvel , Benjamin Herrenschmidt , will.deacon@arm.com, leif.lindholm@linaro.org, roy.franz@linaro.org, Paul Mackerras 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.170 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 Acked-by: Catalin Marinas 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) {}