From patchwork Fri Jan 5 23:20:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 123571 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1403038qgn; Fri, 5 Jan 2018 15:22:20 -0800 (PST) X-Google-Smtp-Source: ACJfBot4rdWjqe78YVSf79n1snYt6RGAVDlH0n7HGV6fOduRiV+kHa2hnjZzapi61vFrvNGm02ge X-Received: by 10.99.112.3 with SMTP id l3mr3725884pgc.152.1515194540530; Fri, 05 Jan 2018 15:22:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515194540; cv=none; d=google.com; s=arc-20160816; b=RslgaBFH8tuvwxjl1RalpzVx7Ukx8XtIT8zf8Ok4IJDiSHWSzY2/zaKLSSFTJXFCls UeU+rny7F+XTuEy+0FZdurMOT9isMr7UR6isGy3EQoztNmM6HESeCGrfTqkIYXu9A7Aq 95HFCLs3BMj6KeEJpLWV6hSIyhom4enZCTd+xaHIXeSu7GdKjgTSUidKCQzfy3M2+0z9 M8dtPQlIxFYJOHIjmkCQJKwk2D4IWa6NORATMCArKukGXeDviXpNOJYkUVIQOfT0+knY JELaG4knK22yvEW2ZjneqnL8mx4aqaJjI5NDKyXGND29PwOs72DPE+o38wBL46FtL5hl Zwqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=jS0EDtKp3J7hEq++QbWurWbGjKfPAZ5R+EzwhkTQI1g=; b=i4D2i1taysCfK5K6Lc+6wGrM+76BZXa2Y++c5SQ9Uhy7UDEBB45jIZJZQuWWzW9cZB WbeKoSUiAW/T1nWTMEqXo2kDEF5hjUTbu0mPcQ/CRLvQMUb+7JuW+FfdHu1+v8AYyYYK UU/p9Qnvb9mNu9w1EkQ/bCxEFoVuTCQpVpEZiD1qLvy8abTcgFJ9jcBiDt4fVGOeUtL0 BtqSrP1a3PX9s+hdmk1XRAuApQSCPQZeKRUG/jmKPZJRPCiCDZ6wDO6XFzQJRrISgMxC f1T1p3nA4y3KsFDqSPpKucJTt7632PZsOGtSqZyqJIJe3+uMrjzJ0NyJ3PoNlytfMZ9H ajCA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h3si4667161pld.448.2018.01.05.15.22.20; Fri, 05 Jan 2018 15:22:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753451AbeAEXWT (ORCPT + 28 others); Fri, 5 Jan 2018 18:22:19 -0500 Received: from mail-ot0-f193.google.com ([74.125.82.193]:41059 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752644AbeAEXU7 (ORCPT ); Fri, 5 Jan 2018 18:20:59 -0500 Received: by mail-ot0-f193.google.com with SMTP id q39so5177530otb.8; Fri, 05 Jan 2018 15:20:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jS0EDtKp3J7hEq++QbWurWbGjKfPAZ5R+EzwhkTQI1g=; b=FbGnoTw7HrvoWrKVYoz5ZZfFBbfdAMbuUbfaV58qAlIaS2vffj16Aak8cCj8m3hllh ZnkMcKNhnvRu1U3ZRPrwsDncTaS0CRP7PQ+FXNsXceqQa6rrja6UE9owcj/oLFeqCAzO cg+xsICrf5wuKBPtlTGyx2OfgL7w6tyikiVLYDsb+miJLvMmAMteVqMXTGAkB1eqJ4Gv Fp+Pt7xjuSjxBhZj5f4bLt+ckEILskQxqzmcmjv1eihG507Z1Nj5lTxQq8F2htvShnup FVb0zKdZ3WcWJnU1a7wBlAitR8auQZhZpnRavWOuHkvT5WLdfrQWNJz1llmmisSmgYU4 +h4Q== X-Gm-Message-State: AKwxytfD1aixFfOcWcQFonhKWZa9bwbdUTNxX2iPSGwPuUPavKDfG/w8 lA5jWfmKewcwVwwlcgLhhENmCLU= X-Received: by 10.157.63.215 with SMTP id i23mr2915809ote.70.1515194458979; Fri, 05 Jan 2018 15:20:58 -0800 (PST) Received: from xps15.usacommunications.tv (216-188-254-6.dyn.grandenetworks.net. [216.188.254.6]) by smtp.googlemail.com with ESMTPSA id u1sm1969998otc.3.2018.01.05.15.20.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 15:20:58 -0800 (PST) From: Rob Herring To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Frank Rowand , Chris Zankel , Max Filippov , linux-xtensa@linux-xtensa.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Ley Foon Tan , nios2-dev@lists.rocketboards.org, Ralf Baechle , linux-mips@linux-mips.org, James Hogan , linux-metag@vger.kernel.org, Mikael Starvik , Jesper Nilsson , linux-cris-kernel@axis.com Subject: [PATCH 1/7] of/fdt: use memblock_virt_alloc for early alloc Date: Fri, 5 Jan 2018 17:20:48 -0600 Message-Id: <20180105232054.27394-2-robh@kernel.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180105232054.27394-1-robh@kernel.org> References: <20180105232054.27394-1-robh@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org memblock_virt_alloc() works for both memblock and bootmem, so use it and make early_init_dt_alloc_memory_arch a static function. The arches using bootmem define early_init_dt_alloc_memory_arch as either: __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS)) or: alloc_bootmem_align(size, align) Both of these evaluate to the same thing as does memblock_virt_alloc for bootmem. So we can disable the arch specific functions by making early_init_dt_alloc_memory_arch static and they can be removed in subsequent commits. Cc: Frank Rowand Signed-off-by: Rob Herring --- drivers/of/fdt.c | 16 ++++------------ drivers/of/unittest.c | 11 ++++++++--- include/linux/of_fdt.h | 1 - 3 files changed, 12 insertions(+), 16 deletions(-) -- 2.14.1 diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 4675e5ac4d11..444e65aa0d29 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -1183,14 +1184,6 @@ int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base, return memblock_reserve(base, size); } -/* - * called from unflatten_device_tree() to bootstrap devicetree itself - * Architectures can override this definition if memblock isn't used - */ -void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align) -{ - return __va(memblock_alloc(size, align)); -} #else void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size) { @@ -1209,13 +1202,12 @@ int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base, &base, &size, nomap ? " (nomap)" : ""); return -ENOSYS; } +#endif -void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align) +static void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) { - WARN_ON(1); - return NULL; + return memblock_virt_alloc(size, align); } -#endif bool __init early_init_dt_verify(void *params) { diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 0f8052f1355c..7a9abaae874d 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -5,6 +5,7 @@ #define pr_fmt(fmt) "### dt-test ### " fmt +#include #include #include #include @@ -2053,6 +2054,11 @@ static struct overlay_info overlays[] = { static struct device_node *overlay_base_root; +static void * __init dt_alloc_memory(u64 size, u64 align) +{ + return memblock_virt_alloc(size, align); +} + /* * Create base device tree for the overlay unittest. * @@ -2092,8 +2098,7 @@ void __init unittest_unflatten_overlay_base(void) return; } - info->data = early_init_dt_alloc_memory_arch(size, - roundup_pow_of_two(FDT_V17_SIZE)); + info->data = dt_alloc_memory(size, roundup_pow_of_two(FDT_V17_SIZE)); if (!info->data) { pr_err("alloc for dtb 'overlay_base' failed"); return; @@ -2102,7 +2107,7 @@ void __init unittest_unflatten_overlay_base(void) memcpy(info->data, info->dtb_begin, size); __unflatten_device_tree(info->data, NULL, &info->np_overlay, - early_init_dt_alloc_memory_arch, true); + dt_alloc_memory, true); overlay_base_root = info->np_overlay; } diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index 444e6e283828..02c05028d0ba 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -83,7 +83,6 @@ extern void early_init_dt_add_memory_arch(u64 base, u64 size); extern int early_init_dt_mark_hotplug_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); -extern void * early_init_dt_alloc_memory_arch(u64 size, u64 align); extern u64 dt_mem_next_cell(int s, const __be32 **cellp); /* Early flat tree scan hooks */