2018-03-14 15:03:41

by Michal Simek

[permalink] [raw]
Subject: [PATCH 1/2] microblaze: remove unused alloc_maybe_bootmem

From: Rob Herring <[email protected]>

alloc_maybe_bootmem is unused, so remove it.

Signed-off-by: Rob Herring <[email protected]>
Signed-off-by: Michal Simek <[email protected]>
---

arch/microblaze/include/asm/setup.h | 1 -
arch/microblaze/mm/init.c | 8 --------
2 files changed, 9 deletions(-)

diff --git a/arch/microblaze/include/asm/setup.h b/arch/microblaze/include/asm/setup.h
index be84a4d3917f..7c968c1d1729 100644
--- a/arch/microblaze/include/asm/setup.h
+++ b/arch/microblaze/include/asm/setup.h
@@ -44,7 +44,6 @@ void machine_early_init(const char *cmdline, unsigned int ram,
void machine_halt(void);
void machine_power_off(void);

-extern void *alloc_maybe_bootmem(size_t size, gfp_t mask);
extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask);

# endif /* __ASSEMBLY__ */
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index 434639f9a3a6..5bc9c7fbb541 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm/init.c
@@ -414,14 +414,6 @@ void __init *early_get_page(void)

#endif /* CONFIG_MMU */

-void * __ref alloc_maybe_bootmem(size_t size, gfp_t mask)
-{
- if (mem_init_done)
- return kmalloc(size, mask);
- else
- return alloc_bootmem(size);
-}
-
void * __ref zalloc_maybe_bootmem(size_t size, gfp_t mask)
{
void *p;
--
1.9.1



2018-03-14 15:05:41

by Michal Simek

[permalink] [raw]
Subject: [PATCH 2/2] microblaze: switch to NO_BOOTMEM

From: Rob Herring <[email protected]>

Microblaze doesn't set CONFIG_NO_BOOTMEM and so memblock_virt_alloc()
doesn't work for CONFIG_HAVE_MEMBLOCK && !CONFIG_NO_BOOTMEM.

Similar change was already done by others architectures
"ARM: mm: Remove bootmem code and switch to NO_BOOTMEM"
(sha1: 84f452b1e8fc73ac0e31254c66e3e2260ce5263d)
or
"openrisc: Consolidate setup to use memblock instead of bootmem"
(sha1: 266c7fad157265bb54d17db1c9545f2aaa488643)
or
"parisc: Drop bootmem and switch to memblock"
(sha1: 4fe9e1d957e45ad8eba9885ee860a0e93d13a7c7)
or
"powerpc: Remove bootmem allocator"
(sha1: 10239733ee8617bac3f1c1769af43a88ed979324)
or
"s390/mm: Convert bootmem to memblock"
(sha1: 50be634507284eea38df78154d22615d21200b42)
or
"sparc64: Convert over to NO_BOOTMEM."
(sha1: 625d693e9784f988371e69c2b41a2172c0be6c11)
or
"xtensa: drop sysmem and switch to memblock"
(sha1: 0e46c1115f5816949220d62dd3ff04aa68e7ac6b)

Issue was introduced by:
"of/fdt: use memblock_virt_alloc for early alloc"
(sha1: 0fa1c579349fdd90173381712ad78aa99c09d38b)

Signed-off-by: Rob Herring <[email protected]>
Tested-by: Alvaro Gamez Machado <[email protected]>
Tested-by: Michal Simek <[email protected]>
Signed-off-by: Michal Simek <[email protected]>
---

arch/microblaze/Kconfig | 1 +
arch/microblaze/mm/init.c | 55 ++++++-----------------------------------------
2 files changed, 7 insertions(+), 49 deletions(-)

diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 4f798aa671dd..3817a3e2146c 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -24,6 +24,7 @@ config MICROBLAZE
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_TRACER
+ select NO_BOOTMEM
select HAVE_MEMBLOCK
select HAVE_MEMBLOCK_NODE_MAP
select HAVE_OPROFILE
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index 5bc9c7fbb541..6ab1ef2daf1d 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm/init.c
@@ -32,9 +32,6 @@
#ifndef CONFIG_MMU
unsigned int __page_offset;
EXPORT_SYMBOL(__page_offset);
-
-#else
-static int init_bootmem_done;
#endif /* CONFIG_MMU */

char *klimit = _end;
@@ -174,17 +171,6 @@ void __init setup_memory(void)
pr_info("%s: max_low_pfn: %#lx\n", __func__, max_low_pfn);
pr_info("%s: max_pfn: %#lx\n", __func__, max_pfn);

- /*
- * Find an area to use for the bootmem bitmap.
- * We look for the first area which is at least
- * 128kB in length (128kB is enough for a bitmap
- * for 4GB of memory, using 4kB pages), plus 1 page
- * (in case the address isn't page-aligned).
- */
- map_size = init_bootmem_node(NODE_DATA(0),
- PFN_UP(TOPHYS((u32)klimit)), min_low_pfn, max_low_pfn);
- memblock_reserve(PFN_UP(TOPHYS((u32)klimit)) << PAGE_SHIFT, map_size);
-
/* Add active regions with valid PFNs */
for_each_memblock(memory, reg) {
unsigned long start_pfn, end_pfn;
@@ -196,32 +182,9 @@ void __init setup_memory(void)
&memblock.memory, 0);
}

- /* free bootmem is whole main memory */
- free_bootmem_with_active_regions(0, max_low_pfn);
-
- /* reserve allocate blocks */
- for_each_memblock(reserved, reg) {
- unsigned long top = reg->base + reg->size - 1;
-
- pr_debug("reserved - 0x%08x-0x%08x, %lx, %lx\n",
- (u32) reg->base, (u32) reg->size, top,
- memory_start + lowmem_size - 1);
-
- if (top <= (memory_start + lowmem_size - 1)) {
- reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT);
- } else if (reg->base < (memory_start + lowmem_size - 1)) {
- unsigned long trunc_size = memory_start + lowmem_size -
- reg->base;
- reserve_bootmem(reg->base, trunc_size, BOOTMEM_DEFAULT);
- }
- }
-
/* XXX need to clip this if using highmem? */
sparse_memory_present_with_active_regions(0);

-#ifdef CONFIG_MMU
- init_bootmem_done = 1;
-#endif
paging_init();
}

@@ -398,18 +361,12 @@ asmlinkage void __init mmu_init(void)
/* This is only called until mem_init is done. */
void __init *early_get_page(void)
{
- void *p;
- if (init_bootmem_done) {
- p = alloc_bootmem_pages(PAGE_SIZE);
- } else {
- /*
- * Mem start + kernel_tlb -> here is limit
- * because of mem mapping from head.S
- */
- p = __va(memblock_alloc_base(PAGE_SIZE, PAGE_SIZE,
- memory_start + kernel_tlb));
- }
- return p;
+ /*
+ * Mem start + kernel_tlb -> here is limit
+ * because of mem mapping from head.S
+ */
+ return __va(memblock_alloc_base(PAGE_SIZE, PAGE_SIZE,
+ memory_start + kernel_tlb));
}

#endif /* CONFIG_MMU */
--
1.9.1


2018-03-14 15:13:10

by Michal Simek

[permalink] [raw]
Subject: Re: [PATCH 2/2] microblaze: switch to NO_BOOTMEM

On 14.3.2018 16:01, Michal Simek wrote:
> From: Rob Herring <[email protected]>
>
> Microblaze doesn't set CONFIG_NO_BOOTMEM and so memblock_virt_alloc()
> doesn't work for CONFIG_HAVE_MEMBLOCK && !CONFIG_NO_BOOTMEM.
>
> Similar change was already done by others architectures
> "ARM: mm: Remove bootmem code and switch to NO_BOOTMEM"
> (sha1: 84f452b1e8fc73ac0e31254c66e3e2260ce5263d)
> or
> "openrisc: Consolidate setup to use memblock instead of bootmem"
> (sha1: 266c7fad157265bb54d17db1c9545f2aaa488643)
> or
> "parisc: Drop bootmem and switch to memblock"
> (sha1: 4fe9e1d957e45ad8eba9885ee860a0e93d13a7c7)
> or
> "powerpc: Remove bootmem allocator"
> (sha1: 10239733ee8617bac3f1c1769af43a88ed979324)
> or
> "s390/mm: Convert bootmem to memblock"
> (sha1: 50be634507284eea38df78154d22615d21200b42)
> or
> "sparc64: Convert over to NO_BOOTMEM."
> (sha1: 625d693e9784f988371e69c2b41a2172c0be6c11)
> or
> "xtensa: drop sysmem and switch to memblock"
> (sha1: 0e46c1115f5816949220d62dd3ff04aa68e7ac6b)
>
> Issue was introduced by:
> "of/fdt: use memblock_virt_alloc for early alloc"
> (sha1: 0fa1c579349fdd90173381712ad78aa99c09d38b)
>
> Signed-off-by: Rob Herring <[email protected]>
> Tested-by: Alvaro Gamez Machado <[email protected]>
> Tested-by: Michal Simek <[email protected]>
> Signed-off-by: Michal Simek <[email protected]>
> ---
>
> arch/microblaze/Kconfig | 1 +
> arch/microblaze/mm/init.c | 55 ++++++-----------------------------------------
> 2 files changed, 7 insertions(+), 49 deletions(-)
>
> diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
> index 4f798aa671dd..3817a3e2146c 100644
> --- a/arch/microblaze/Kconfig
> +++ b/arch/microblaze/Kconfig
> @@ -24,6 +24,7 @@ config MICROBLAZE
> select HAVE_FTRACE_MCOUNT_RECORD
> select HAVE_FUNCTION_GRAPH_TRACER
> select HAVE_FUNCTION_TRACER
> + select NO_BOOTMEM
> select HAVE_MEMBLOCK
> select HAVE_MEMBLOCK_NODE_MAP
> select HAVE_OPROFILE
> diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
> index 5bc9c7fbb541..6ab1ef2daf1d 100644
> --- a/arch/microblaze/mm/init.c
> +++ b/arch/microblaze/mm/init.c
> @@ -32,9 +32,6 @@
> #ifndef CONFIG_MMU
> unsigned int __page_offset;
> EXPORT_SYMBOL(__page_offset);
> -
> -#else
> -static int init_bootmem_done;
> #endif /* CONFIG_MMU */
>
> char *klimit = _end;
> @@ -174,17 +171,6 @@ void __init setup_memory(void)
> pr_info("%s: max_low_pfn: %#lx\n", __func__, max_low_pfn);
> pr_info("%s: max_pfn: %#lx\n", __func__, max_pfn);
>
> - /*
> - * Find an area to use for the bootmem bitmap.
> - * We look for the first area which is at least
> - * 128kB in length (128kB is enough for a bitmap
> - * for 4GB of memory, using 4kB pages), plus 1 page
> - * (in case the address isn't page-aligned).
> - */
> - map_size = init_bootmem_node(NODE_DATA(0),

map_size variable should be also removed. Fixed in v2.

Thanks,
Michal

--
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: http://www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP SoCs



Attachments:
signature.asc (205.00 B)
OpenPGP digital signature