Re: [PATCH] h8300: switch to NO_BOOTMEM

2018-05-08 Thread Yoshinori Sato
On Sat, 17 Mar 2018 06:33:06 +0900,
Rob Herring wrote:
> 
> Commit 0fa1c579349f ("of/fdt: use memblock_virt_alloc for early alloc")
> inadvertently switched the DT unflattening allocations from memblock to
> bootmem which doesn't work because the unflattening happens before
> bootmem is initialized. Swapping the order of bootmem init and
> unflattening could also fix this, but removing bootmem is desired. So
> enable NO_BOOTMEM on h8300 like other architectures have done.
> 
> Fixes: 0fa1c579349f ("of/fdt: use memblock_virt_alloc for early alloc")
> Cc: Yoshinori Sato 
> Cc: uclinux-h8-de...@lists.sourceforge.jp
> Signed-off-by: Rob Herring 
> ---
> I haven't seen any reports, but 4.16 is likely broken. This is compile 
> tested only.
> 
> Moving unflattening after bootmem_init should also work if a smaller 
> change for 4.16 is desired.

It's works fine.
Applied to h8300-next.

Thanks.

> Rob
> 
>  arch/h8300/Kconfig|  1 +
>  arch/h8300/kernel/setup.c | 36 
>  2 files changed, 9 insertions(+), 28 deletions(-)
> 
> diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
> index 091d6d04b5e5..efc602634064 100644
> --- a/arch/h8300/Kconfig
> +++ b/arch/h8300/Kconfig
> @@ -16,6 +16,7 @@ config H8300
>   select OF_IRQ
>   select OF_EARLY_FLATTREE
>   select HAVE_MEMBLOCK
> + select NO_BOOTMEM
>   select TIMER_OF
>   select H8300_TMR8
>   select HAVE_KERNEL_GZIP
> diff --git a/arch/h8300/kernel/setup.c b/arch/h8300/kernel/setup.c
> index a4d0470c10a9..33ed980e7aea 100644
> --- a/arch/h8300/kernel/setup.c
> +++ b/arch/h8300/kernel/setup.c
> @@ -71,10 +71,6 @@ void __init h8300_fdt_init(void *fdt, char *bootargs)
>  
>  static void __init bootmem_init(void)
>  {
> - int bootmap_size;
> - unsigned long ram_start_pfn;
> - unsigned long free_ram_start_pfn;
> - unsigned long ram_end_pfn;
>   struct memblock_region *region;
>  
>   memory_end = memory_start = 0;
> @@ -88,33 +84,17 @@ static void __init bootmem_init(void)
>   if (!memory_end)
>   panic("No memory!");
>  
> - ram_start_pfn = PFN_UP(memory_start);
> - /* free_ram_start_pfn is first page after kernel */
> - free_ram_start_pfn = PFN_UP(__pa(_end));
> - ram_end_pfn = PFN_DOWN(memblock_end_of_DRAM());
> + /* setup bootmem globals (we use no_bootmem, but mm still depends on 
> this) */
> + min_low_pfn = PFN_UP(memory_start);
> + max_low_pfn = PFN_DOWN(memblock_end_of_DRAM());
> + max_pfn = max_low_pfn;
>  
> - max_pfn = ram_end_pfn;
> + memblock_reserve(__pa(_stext), _end - _stext);
>  
> - /*
> -  * give all the memory to the bootmap allocator,  tell it to put the
> -  * boot mem_map at the start of memory
> -  */
> - bootmap_size = init_bootmem_node(NODE_DATA(0),
> -  free_ram_start_pfn,
> -  0,
> -  ram_end_pfn);
> - /*
> -  * free the usable memory,  we have to make sure we do not free
> -  * the bootmem bitmap so we then reserve it after freeing it :-)
> -  */
> - free_bootmem(PFN_PHYS(free_ram_start_pfn),
> -  (ram_end_pfn - free_ram_start_pfn) << PAGE_SHIFT);
> - reserve_bootmem(PFN_PHYS(free_ram_start_pfn), bootmap_size,
> - BOOTMEM_DEFAULT);
> + early_init_fdt_reserve_self();
> + early_init_fdt_scan_reserved_mem();
>  
> - for_each_memblock(reserved, region) {
> - reserve_bootmem(region->base, region->size, BOOTMEM_DEFAULT);
> - }
> + memblock_dump_all();
>  }
>  
>  void __init setup_arch(char **cmdline_p)
> -- 
> 2.14.1
> 

-- 
Yoshinori Sato



Re: [PATCH] h8300: switch to NO_BOOTMEM

2018-05-08 Thread Yoshinori Sato
On Sat, 17 Mar 2018 06:33:06 +0900,
Rob Herring wrote:
> 
> Commit 0fa1c579349f ("of/fdt: use memblock_virt_alloc for early alloc")
> inadvertently switched the DT unflattening allocations from memblock to
> bootmem which doesn't work because the unflattening happens before
> bootmem is initialized. Swapping the order of bootmem init and
> unflattening could also fix this, but removing bootmem is desired. So
> enable NO_BOOTMEM on h8300 like other architectures have done.
> 
> Fixes: 0fa1c579349f ("of/fdt: use memblock_virt_alloc for early alloc")
> Cc: Yoshinori Sato 
> Cc: uclinux-h8-de...@lists.sourceforge.jp
> Signed-off-by: Rob Herring 
> ---
> I haven't seen any reports, but 4.16 is likely broken. This is compile 
> tested only.
> 
> Moving unflattening after bootmem_init should also work if a smaller 
> change for 4.16 is desired.

It's works fine.
Applied to h8300-next.

Thanks.

> Rob
> 
>  arch/h8300/Kconfig|  1 +
>  arch/h8300/kernel/setup.c | 36 
>  2 files changed, 9 insertions(+), 28 deletions(-)
> 
> diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
> index 091d6d04b5e5..efc602634064 100644
> --- a/arch/h8300/Kconfig
> +++ b/arch/h8300/Kconfig
> @@ -16,6 +16,7 @@ config H8300
>   select OF_IRQ
>   select OF_EARLY_FLATTREE
>   select HAVE_MEMBLOCK
> + select NO_BOOTMEM
>   select TIMER_OF
>   select H8300_TMR8
>   select HAVE_KERNEL_GZIP
> diff --git a/arch/h8300/kernel/setup.c b/arch/h8300/kernel/setup.c
> index a4d0470c10a9..33ed980e7aea 100644
> --- a/arch/h8300/kernel/setup.c
> +++ b/arch/h8300/kernel/setup.c
> @@ -71,10 +71,6 @@ void __init h8300_fdt_init(void *fdt, char *bootargs)
>  
>  static void __init bootmem_init(void)
>  {
> - int bootmap_size;
> - unsigned long ram_start_pfn;
> - unsigned long free_ram_start_pfn;
> - unsigned long ram_end_pfn;
>   struct memblock_region *region;
>  
>   memory_end = memory_start = 0;
> @@ -88,33 +84,17 @@ static void __init bootmem_init(void)
>   if (!memory_end)
>   panic("No memory!");
>  
> - ram_start_pfn = PFN_UP(memory_start);
> - /* free_ram_start_pfn is first page after kernel */
> - free_ram_start_pfn = PFN_UP(__pa(_end));
> - ram_end_pfn = PFN_DOWN(memblock_end_of_DRAM());
> + /* setup bootmem globals (we use no_bootmem, but mm still depends on 
> this) */
> + min_low_pfn = PFN_UP(memory_start);
> + max_low_pfn = PFN_DOWN(memblock_end_of_DRAM());
> + max_pfn = max_low_pfn;
>  
> - max_pfn = ram_end_pfn;
> + memblock_reserve(__pa(_stext), _end - _stext);
>  
> - /*
> -  * give all the memory to the bootmap allocator,  tell it to put the
> -  * boot mem_map at the start of memory
> -  */
> - bootmap_size = init_bootmem_node(NODE_DATA(0),
> -  free_ram_start_pfn,
> -  0,
> -  ram_end_pfn);
> - /*
> -  * free the usable memory,  we have to make sure we do not free
> -  * the bootmem bitmap so we then reserve it after freeing it :-)
> -  */
> - free_bootmem(PFN_PHYS(free_ram_start_pfn),
> -  (ram_end_pfn - free_ram_start_pfn) << PAGE_SHIFT);
> - reserve_bootmem(PFN_PHYS(free_ram_start_pfn), bootmap_size,
> - BOOTMEM_DEFAULT);
> + early_init_fdt_reserve_self();
> + early_init_fdt_scan_reserved_mem();
>  
> - for_each_memblock(reserved, region) {
> - reserve_bootmem(region->base, region->size, BOOTMEM_DEFAULT);
> - }
> + memblock_dump_all();
>  }
>  
>  void __init setup_arch(char **cmdline_p)
> -- 
> 2.14.1
> 

-- 
Yoshinori Sato



Re: [PATCH] h8300: switch to NO_BOOTMEM

2018-05-02 Thread Yoshinori Sato
On Wed, 02 May 2018 11:33:41 +0900,
Rob Herring wrote:
> 
> On Fri, Mar 16, 2018 at 4:33 PM, Rob Herring  wrote:
> > Commit 0fa1c579349f ("of/fdt: use memblock_virt_alloc for early alloc")
> > inadvertently switched the DT unflattening allocations from memblock to
> > bootmem which doesn't work because the unflattening happens before
> > bootmem is initialized. Swapping the order of bootmem init and
> > unflattening could also fix this, but removing bootmem is desired. So
> > enable NO_BOOTMEM on h8300 like other architectures have done.
> >
> > Fixes: 0fa1c579349f ("of/fdt: use memblock_virt_alloc for early alloc")
> > Cc: Yoshinori Sato 
> > Cc: uclinux-h8-de...@lists.sourceforge.jp
> > Signed-off-by: Rob Herring 
> > ---
> > I haven't seen any reports, but 4.16 is likely broken. This is compile
> > tested only.
> >
> > Moving unflattening after bootmem_init should also work if a smaller
> > change for 4.16 is desired.
> 
> Ping! Someone going to pick this up?
> 
> Rob

Sorry. I looked out.
Please wait several days to confirm.

-- 
Yosinori Sato


Re: [PATCH] h8300: switch to NO_BOOTMEM

2018-05-02 Thread Yoshinori Sato
On Wed, 02 May 2018 11:33:41 +0900,
Rob Herring wrote:
> 
> On Fri, Mar 16, 2018 at 4:33 PM, Rob Herring  wrote:
> > Commit 0fa1c579349f ("of/fdt: use memblock_virt_alloc for early alloc")
> > inadvertently switched the DT unflattening allocations from memblock to
> > bootmem which doesn't work because the unflattening happens before
> > bootmem is initialized. Swapping the order of bootmem init and
> > unflattening could also fix this, but removing bootmem is desired. So
> > enable NO_BOOTMEM on h8300 like other architectures have done.
> >
> > Fixes: 0fa1c579349f ("of/fdt: use memblock_virt_alloc for early alloc")
> > Cc: Yoshinori Sato 
> > Cc: uclinux-h8-de...@lists.sourceforge.jp
> > Signed-off-by: Rob Herring 
> > ---
> > I haven't seen any reports, but 4.16 is likely broken. This is compile
> > tested only.
> >
> > Moving unflattening after bootmem_init should also work if a smaller
> > change for 4.16 is desired.
> 
> Ping! Someone going to pick this up?
> 
> Rob

Sorry. I looked out.
Please wait several days to confirm.

-- 
Yosinori Sato


Re: [PATCH] h8300: switch to NO_BOOTMEM

2018-05-01 Thread Rob Herring
On Fri, Mar 16, 2018 at 4:33 PM, Rob Herring  wrote:
> Commit 0fa1c579349f ("of/fdt: use memblock_virt_alloc for early alloc")
> inadvertently switched the DT unflattening allocations from memblock to
> bootmem which doesn't work because the unflattening happens before
> bootmem is initialized. Swapping the order of bootmem init and
> unflattening could also fix this, but removing bootmem is desired. So
> enable NO_BOOTMEM on h8300 like other architectures have done.
>
> Fixes: 0fa1c579349f ("of/fdt: use memblock_virt_alloc for early alloc")
> Cc: Yoshinori Sato 
> Cc: uclinux-h8-de...@lists.sourceforge.jp
> Signed-off-by: Rob Herring 
> ---
> I haven't seen any reports, but 4.16 is likely broken. This is compile
> tested only.
>
> Moving unflattening after bootmem_init should also work if a smaller
> change for 4.16 is desired.

Ping! Someone going to pick this up?

Rob


Re: [PATCH] h8300: switch to NO_BOOTMEM

2018-05-01 Thread Rob Herring
On Fri, Mar 16, 2018 at 4:33 PM, Rob Herring  wrote:
> Commit 0fa1c579349f ("of/fdt: use memblock_virt_alloc for early alloc")
> inadvertently switched the DT unflattening allocations from memblock to
> bootmem which doesn't work because the unflattening happens before
> bootmem is initialized. Swapping the order of bootmem init and
> unflattening could also fix this, but removing bootmem is desired. So
> enable NO_BOOTMEM on h8300 like other architectures have done.
>
> Fixes: 0fa1c579349f ("of/fdt: use memblock_virt_alloc for early alloc")
> Cc: Yoshinori Sato 
> Cc: uclinux-h8-de...@lists.sourceforge.jp
> Signed-off-by: Rob Herring 
> ---
> I haven't seen any reports, but 4.16 is likely broken. This is compile
> tested only.
>
> Moving unflattening after bootmem_init should also work if a smaller
> change for 4.16 is desired.

Ping! Someone going to pick this up?

Rob


[PATCH] h8300: switch to NO_BOOTMEM

2018-03-16 Thread Rob Herring
Commit 0fa1c579349f ("of/fdt: use memblock_virt_alloc for early alloc")
inadvertently switched the DT unflattening allocations from memblock to
bootmem which doesn't work because the unflattening happens before
bootmem is initialized. Swapping the order of bootmem init and
unflattening could also fix this, but removing bootmem is desired. So
enable NO_BOOTMEM on h8300 like other architectures have done.

Fixes: 0fa1c579349f ("of/fdt: use memblock_virt_alloc for early alloc")
Cc: Yoshinori Sato 
Cc: uclinux-h8-de...@lists.sourceforge.jp
Signed-off-by: Rob Herring 
---
I haven't seen any reports, but 4.16 is likely broken. This is compile 
tested only.

Moving unflattening after bootmem_init should also work if a smaller 
change for 4.16 is desired.

Rob

 arch/h8300/Kconfig|  1 +
 arch/h8300/kernel/setup.c | 36 
 2 files changed, 9 insertions(+), 28 deletions(-)

diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index 091d6d04b5e5..efc602634064 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -16,6 +16,7 @@ config H8300
select OF_IRQ
select OF_EARLY_FLATTREE
select HAVE_MEMBLOCK
+   select NO_BOOTMEM
select TIMER_OF
select H8300_TMR8
select HAVE_KERNEL_GZIP
diff --git a/arch/h8300/kernel/setup.c b/arch/h8300/kernel/setup.c
index a4d0470c10a9..33ed980e7aea 100644
--- a/arch/h8300/kernel/setup.c
+++ b/arch/h8300/kernel/setup.c
@@ -71,10 +71,6 @@ void __init h8300_fdt_init(void *fdt, char *bootargs)
 
 static void __init bootmem_init(void)
 {
-   int bootmap_size;
-   unsigned long ram_start_pfn;
-   unsigned long free_ram_start_pfn;
-   unsigned long ram_end_pfn;
struct memblock_region *region;
 
memory_end = memory_start = 0;
@@ -88,33 +84,17 @@ static void __init bootmem_init(void)
if (!memory_end)
panic("No memory!");
 
-   ram_start_pfn = PFN_UP(memory_start);
-   /* free_ram_start_pfn is first page after kernel */
-   free_ram_start_pfn = PFN_UP(__pa(_end));
-   ram_end_pfn = PFN_DOWN(memblock_end_of_DRAM());
+   /* setup bootmem globals (we use no_bootmem, but mm still depends on 
this) */
+   min_low_pfn = PFN_UP(memory_start);
+   max_low_pfn = PFN_DOWN(memblock_end_of_DRAM());
+   max_pfn = max_low_pfn;
 
-   max_pfn = ram_end_pfn;
+   memblock_reserve(__pa(_stext), _end - _stext);
 
-   /*
-* give all the memory to the bootmap allocator,  tell it to put the
-* boot mem_map at the start of memory
-*/
-   bootmap_size = init_bootmem_node(NODE_DATA(0),
-free_ram_start_pfn,
-0,
-ram_end_pfn);
-   /*
-* free the usable memory,  we have to make sure we do not free
-* the bootmem bitmap so we then reserve it after freeing it :-)
-*/
-   free_bootmem(PFN_PHYS(free_ram_start_pfn),
-(ram_end_pfn - free_ram_start_pfn) << PAGE_SHIFT);
-   reserve_bootmem(PFN_PHYS(free_ram_start_pfn), bootmap_size,
-   BOOTMEM_DEFAULT);
+   early_init_fdt_reserve_self();
+   early_init_fdt_scan_reserved_mem();
 
-   for_each_memblock(reserved, region) {
-   reserve_bootmem(region->base, region->size, BOOTMEM_DEFAULT);
-   }
+   memblock_dump_all();
 }
 
 void __init setup_arch(char **cmdline_p)
-- 
2.14.1



[PATCH] h8300: switch to NO_BOOTMEM

2018-03-16 Thread Rob Herring
Commit 0fa1c579349f ("of/fdt: use memblock_virt_alloc for early alloc")
inadvertently switched the DT unflattening allocations from memblock to
bootmem which doesn't work because the unflattening happens before
bootmem is initialized. Swapping the order of bootmem init and
unflattening could also fix this, but removing bootmem is desired. So
enable NO_BOOTMEM on h8300 like other architectures have done.

Fixes: 0fa1c579349f ("of/fdt: use memblock_virt_alloc for early alloc")
Cc: Yoshinori Sato 
Cc: uclinux-h8-de...@lists.sourceforge.jp
Signed-off-by: Rob Herring 
---
I haven't seen any reports, but 4.16 is likely broken. This is compile 
tested only.

Moving unflattening after bootmem_init should also work if a smaller 
change for 4.16 is desired.

Rob

 arch/h8300/Kconfig|  1 +
 arch/h8300/kernel/setup.c | 36 
 2 files changed, 9 insertions(+), 28 deletions(-)

diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index 091d6d04b5e5..efc602634064 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -16,6 +16,7 @@ config H8300
select OF_IRQ
select OF_EARLY_FLATTREE
select HAVE_MEMBLOCK
+   select NO_BOOTMEM
select TIMER_OF
select H8300_TMR8
select HAVE_KERNEL_GZIP
diff --git a/arch/h8300/kernel/setup.c b/arch/h8300/kernel/setup.c
index a4d0470c10a9..33ed980e7aea 100644
--- a/arch/h8300/kernel/setup.c
+++ b/arch/h8300/kernel/setup.c
@@ -71,10 +71,6 @@ void __init h8300_fdt_init(void *fdt, char *bootargs)
 
 static void __init bootmem_init(void)
 {
-   int bootmap_size;
-   unsigned long ram_start_pfn;
-   unsigned long free_ram_start_pfn;
-   unsigned long ram_end_pfn;
struct memblock_region *region;
 
memory_end = memory_start = 0;
@@ -88,33 +84,17 @@ static void __init bootmem_init(void)
if (!memory_end)
panic("No memory!");
 
-   ram_start_pfn = PFN_UP(memory_start);
-   /* free_ram_start_pfn is first page after kernel */
-   free_ram_start_pfn = PFN_UP(__pa(_end));
-   ram_end_pfn = PFN_DOWN(memblock_end_of_DRAM());
+   /* setup bootmem globals (we use no_bootmem, but mm still depends on 
this) */
+   min_low_pfn = PFN_UP(memory_start);
+   max_low_pfn = PFN_DOWN(memblock_end_of_DRAM());
+   max_pfn = max_low_pfn;
 
-   max_pfn = ram_end_pfn;
+   memblock_reserve(__pa(_stext), _end - _stext);
 
-   /*
-* give all the memory to the bootmap allocator,  tell it to put the
-* boot mem_map at the start of memory
-*/
-   bootmap_size = init_bootmem_node(NODE_DATA(0),
-free_ram_start_pfn,
-0,
-ram_end_pfn);
-   /*
-* free the usable memory,  we have to make sure we do not free
-* the bootmem bitmap so we then reserve it after freeing it :-)
-*/
-   free_bootmem(PFN_PHYS(free_ram_start_pfn),
-(ram_end_pfn - free_ram_start_pfn) << PAGE_SHIFT);
-   reserve_bootmem(PFN_PHYS(free_ram_start_pfn), bootmap_size,
-   BOOTMEM_DEFAULT);
+   early_init_fdt_reserve_self();
+   early_init_fdt_scan_reserved_mem();
 
-   for_each_memblock(reserved, region) {
-   reserve_bootmem(region->base, region->size, BOOTMEM_DEFAULT);
-   }
+   memblock_dump_all();
 }
 
 void __init setup_arch(char **cmdline_p)
-- 
2.14.1