devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robh@kernel.org>
To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Frank Rowand <frowand.list@gmail.com>,
	Chris Zankel <chris@zankel.net>,
	Max Filippov <jcmvbkbc@gmail.com>,
	linux-xtensa@linux-xtensa.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, Ley Foon Tan <lftan@altera.com>,
	nios2-dev@lists.rocketboards.org,
	Ralf Baechle <ralf@linux-mips.org>,
	linux-mips@linux-mips.org, James Hogan <jhogan@kernel.org>,
	linux-metag@vger.kernel.org, Mikael Starvik <starvik@axis.com>,
	Jesper Nilsson <jesper.nilsson@axis.com>,
	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	[thread overview]
Message-ID: <20180105232054.27394-2-robh@kernel.org> (raw)
In-Reply-To: <20180105232054.27394-1-robh@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 <frowand.list@gmail.com>
Signed-off-by: Rob Herring <robh@kernel.org>
---
 drivers/of/fdt.c       | 16 ++++------------
 drivers/of/unittest.c  | 11 ++++++++---
 include/linux/of_fdt.h |  1 -
 3 files changed, 12 insertions(+), 16 deletions(-)

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 <linux/crc32.h>
 #include <linux/kernel.h>
 #include <linux/initrd.h>
+#include <linux/bootmem.h>
 #include <linux/memblock.h>
 #include <linux/mutex.h>
 #include <linux/of.h>
@@ -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 <linux/bootmem.h>
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/errno.h>
@@ -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 */
--
2.14.1

  reply	other threads:[~2018-01-05 23:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-05 23:20 [PATCH 0/7] DT: consolidate bootmem support Rob Herring
2018-01-05 23:20 ` Rob Herring [this message]
2018-01-05 23:20 ` [PATCH 2/7] cris: remove arch specific early DT functions Rob Herring
2018-01-05 23:20 ` [PATCH 3/7] metag: " Rob Herring
2018-01-05 23:20 ` [PATCH 4/7] mips: remove arch specific early_init_dt_alloc_memory_arch Rob Herring
2018-01-05 23:20 ` [PATCH 5/7] nios2: " Rob Herring
     [not found]   ` <20180105232054.27394-6-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2018-01-17 11:00     ` Tobias Klauser
2018-01-05 23:20 ` [PATCH 6/7] x86: " Rob Herring
2018-01-05 23:20 ` [PATCH 7/7] xtensa: remove arch specific early DT functions Rob Herring
2018-01-15  9:13   ` Max Filippov
  -- strict thread matches above, loose matches on Subject: below --
2018-01-05 23:14 [PATCH 0/7] DT: consolidate bootmem support Rob Herring
     [not found] ` <20180105231424.19247-1-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2018-01-05 23:14   ` [PATCH 1/7] of/fdt: use memblock_virt_alloc for early alloc Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180105232054.27394-2-robh@kernel.org \
    --to=robh@kernel.org \
    --cc=chris@zankel.net \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jcmvbkbc@gmail.com \
    --cc=jesper.nilsson@axis.com \
    --cc=jhogan@kernel.org \
    --cc=lftan@altera.com \
    --cc=linux-cris-kernel@axis.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-metag@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=linux-xtensa@linux-xtensa.org \
    --cc=mingo@redhat.com \
    --cc=nios2-dev@lists.rocketboards.org \
    --cc=ralf@linux-mips.org \
    --cc=starvik@axis.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).