From patchwork Fri Apr 10 13:53:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 6197011 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5224D9F2E9 for ; Fri, 10 Apr 2015 14:00:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 508CA2021B for ; Fri, 10 Apr 2015 14:00:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5EFEE201BC for ; Fri, 10 Apr 2015 14:00:06 +0000 (UTC) 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 1YgZQd-0000kC-Dp; Fri, 10 Apr 2015 13:57:03 +0000 Received: from mail-wi0-f172.google.com ([209.85.212.172]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YgZOJ-0006GJ-GS for linux-arm-kernel@lists.infradead.org; Fri, 10 Apr 2015 13:54:41 +0000 Received: by wiaa2 with SMTP id a2so27472995wia.0 for ; Fri, 10 Apr 2015 06:54:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Hx8mQqjVSaoVXBYGChXs3ldhbdOHMZJA0T5fHc4+gOE=; b=S5Gnx+0alhpgHqO1enmZS891jwkhlihPFn8J4CqaC3KILQthyTuqmk+JwMdcVfm57U oj61kSude/QnvWPSEaThdR+vRfFXohYqPg+cgNDwQbggAu8HaCjf1gS53lMDMAHswK0b YLRaL21UxXwTMH6O4wz8fOMU1Wc9o/A3D4SQFhQCjjY8sz86iyNmBcAdosdE1G+TExaM YZ9HWDJaIwOwfshdw4Pr2rxdfvD0j75u3+Gp0/MP1gN36R53oep8TX/EOnO7TfVu6tHS IJnaw54WOdNUeR5yNnw7qDQou9ueJ4UZq74Q+HscwEuQ0cKjGM+gfOrSW4CU18nnnKzR 1HxQ== X-Gm-Message-State: ALoCoQm9sskUvxLxH4+Pp9tu9aa4BViBSPQ/mgKTDlLlQbjHDrMNmPZ1FYLVoV08Ty+kJ0TSujis X-Received: by 10.180.96.65 with SMTP id dq1mr15468318wib.46.1428674053811; Fri, 10 Apr 2015 06:54:13 -0700 (PDT) Received: from ards-macbook-pro.local ([84.78.25.50]) by mx.google.com with ESMTPSA id e2sm3051482wjy.46.2015.04.10.06.54.11 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 10 Apr 2015 06:54:12 -0700 (PDT) From: Ard Biesheuvel To: mark.rutland@arm.com, catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 03/11] of/fdt: split off FDT self reservation from memreserve processing Date: Fri, 10 Apr 2015 15:53:47 +0200 Message-Id: <1428674035-26603-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1428674035-26603-1-git-send-email-ard.biesheuvel@linaro.org> References: <1428674035-26603-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150410_065439_779215_FD2995D6 X-CRM114-Status: GOOD ( 15.53 ) X-Spam-Score: -0.7 (/) Cc: Benjamin Herrenschmidt , Russell King , 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 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) {}