diff mbox series

[2/2] MIPS: loongson64: set nid for reserved memblock region

Message ID 20240123014758.12718-2-huangpei@loongson.cn (mailing list archive)
State Accepted
Commit ce7b1b97776ec0b068c4dd6b6dbb48ae09a23519
Headers show
Series [1/2] MIPS: reserve exception vector space ONLY ONCE | expand

Commit Message

Huang Pei Jan. 23, 2024, 1:47 a.m. UTC
Commit 61167ad5fecd("mm: pass nid to reserve_bootmem_region()") reveals
that reserved memblock regions have no valid node id set, just set it
right since loongson64 firmware makes it clear in memory layout info.

This works around booting failure on 3A1000+ since commit 61167ad5fecd
("mm: pass nid to reserve_bootmem_region()") under
CONFIG_DEFERRED_STRUCT_PAGE_INIT.

Signed-off-by: Huang Pei <huangpei@loongson.cn>
---
 arch/mips/loongson64/init.c | 2 ++
 arch/mips/loongson64/numa.c | 2 ++
 2 files changed, 4 insertions(+)

Comments

Thomas Bogendoerfer Jan. 26, 2024, 10:12 a.m. UTC | #1
On Tue, Jan 23, 2024 at 09:47:58AM +0800, Huang Pei wrote:
> Commit 61167ad5fecd("mm: pass nid to reserve_bootmem_region()") reveals
> that reserved memblock regions have no valid node id set, just set it
> right since loongson64 firmware makes it clear in memory layout info.
> 
> This works around booting failure on 3A1000+ since commit 61167ad5fecd
> ("mm: pass nid to reserve_bootmem_region()") under
> CONFIG_DEFERRED_STRUCT_PAGE_INIT.
> 
> Signed-off-by: Huang Pei <huangpei@loongson.cn>
> ---
>  arch/mips/loongson64/init.c | 2 ++
>  arch/mips/loongson64/numa.c | 2 ++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/arch/mips/loongson64/init.c b/arch/mips/loongson64/init.c
> index f25caa6aa9d3..000ba91c0886 100644
> --- a/arch/mips/loongson64/init.c
> +++ b/arch/mips/loongson64/init.c
> @@ -103,6 +103,8 @@ void __init szmem(unsigned int node)
>  	if (loongson_sysconf.vgabios_addr)
>  		memblock_reserve(virt_to_phys((void *)loongson_sysconf.vgabios_addr),
>  				SZ_256K);
> +	/* set nid for reserved memory */
> +	memblock_set_node((u64)node << 44, (u64)(node+1) << 44, &memblock.reserved, node);
>  }
>  
>  #ifndef CONFIG_NUMA
> diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c
> index 8f61e93c0c5b..6345e096c532 100644
> --- a/arch/mips/loongson64/numa.c
> +++ b/arch/mips/loongson64/numa.c
> @@ -132,6 +132,8 @@ static void __init node_mem_init(unsigned int node)
>  
>  		/* Reserve pfn range 0~node[0]->node_start_pfn */
>  		memblock_reserve(0, PAGE_SIZE * start_pfn);
> +		/* set nid for reserved memory on node 0 */
> +		memblock_set_node(0, (u64)1 << 44, &memblock.reserved, 1);
>  	}
>  }
>  
> -- 
> 2.30.2

applied to mips-fixes.

Thomas.
Huacai Chen Jan. 26, 2024, 2:24 p.m. UTC | #2
On Fri, Jan 26, 2024 at 6:30 PM Thomas Bogendoerfer
<tsbogend@alpha.franken.de> wrote:
>
> On Tue, Jan 23, 2024 at 09:47:58AM +0800, Huang Pei wrote:
> > Commit 61167ad5fecd("mm: pass nid to reserve_bootmem_region()") reveals
> > that reserved memblock regions have no valid node id set, just set it
> > right since loongson64 firmware makes it clear in memory layout info.
> >
> > This works around booting failure on 3A1000+ since commit 61167ad5fecd
> > ("mm: pass nid to reserve_bootmem_region()") under
> > CONFIG_DEFERRED_STRUCT_PAGE_INIT.
> >
> > Signed-off-by: Huang Pei <huangpei@loongson.cn>
> > ---
> >  arch/mips/loongson64/init.c | 2 ++
> >  arch/mips/loongson64/numa.c | 2 ++
> >  2 files changed, 4 insertions(+)
> >
> > diff --git a/arch/mips/loongson64/init.c b/arch/mips/loongson64/init.c
> > index f25caa6aa9d3..000ba91c0886 100644
> > --- a/arch/mips/loongson64/init.c
> > +++ b/arch/mips/loongson64/init.c
> > @@ -103,6 +103,8 @@ void __init szmem(unsigned int node)
> >       if (loongson_sysconf.vgabios_addr)
> >               memblock_reserve(virt_to_phys((void *)loongson_sysconf.vgabios_addr),
> >                               SZ_256K);
> > +     /* set nid for reserved memory */
> > +     memblock_set_node((u64)node << 44, (u64)(node+1) << 44, &memblock.reserved, node);
> >  }
> >
> >  #ifndef CONFIG_NUMA
> > diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c
> > index 8f61e93c0c5b..6345e096c532 100644
> > --- a/arch/mips/loongson64/numa.c
> > +++ b/arch/mips/loongson64/numa.c
> > @@ -132,6 +132,8 @@ static void __init node_mem_init(unsigned int node)
> >
> >               /* Reserve pfn range 0~node[0]->node_start_pfn */
> >               memblock_reserve(0, PAGE_SIZE * start_pfn);
> > +             /* set nid for reserved memory on node 0 */
> > +             memblock_set_node(0, (u64)1 << 44, &memblock.reserved, 1);
> >       }
> >  }
> >
> > --
> > 2.30.2
>
> applied to mips-fixes.
Oh, I'm sorry that I found a very stupid error in this patch. The
comment says set memory on node 0 but the code set it on node 1...

Huacai

>
> Thomas.
>
> --
> Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
> good idea.                                                [ RFC1925, 2.3 ]
>
Thomas Bogendoerfer Jan. 26, 2024, 5:24 p.m. UTC | #3
On Fri, Jan 26, 2024 at 10:24:29PM +0800, Huacai Chen wrote:
> On Fri, Jan 26, 2024 at 6:30 PM Thomas Bogendoerfer
> <tsbogend@alpha.franken.de> wrote:
> >
> > On Tue, Jan 23, 2024 at 09:47:58AM +0800, Huang Pei wrote:
> > [...]
> > > diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c
> > > index 8f61e93c0c5b..6345e096c532 100644
> > > --- a/arch/mips/loongson64/numa.c
> > > +++ b/arch/mips/loongson64/numa.c
> > > @@ -132,6 +132,8 @@ static void __init node_mem_init(unsigned int node)
> > >
> > >               /* Reserve pfn range 0~node[0]->node_start_pfn */
> > >               memblock_reserve(0, PAGE_SIZE * start_pfn);
> > > +             /* set nid for reserved memory on node 0 */
> > > +             memblock_set_node(0, (u64)1 << 44, &memblock.reserved, 1);
> > >       }
> > >  }
> > >
> > > --
> > > 2.30.2
> >
> > applied to mips-fixes.
> Oh, I'm sorry that I found a very stupid error in this patch. The
> comment says set memory on node 0 but the code set it on node 1...

and what is correct ? Please send a patch to fix it in mips-fixes.

Thomas.
Huang Pei Jan. 27, 2024, 9:12 a.m. UTC | #4
fix wrong nid for node0's reserved memblock region.
diff mbox series

Patch

diff --git a/arch/mips/loongson64/init.c b/arch/mips/loongson64/init.c
index f25caa6aa9d3..000ba91c0886 100644
--- a/arch/mips/loongson64/init.c
+++ b/arch/mips/loongson64/init.c
@@ -103,6 +103,8 @@  void __init szmem(unsigned int node)
 	if (loongson_sysconf.vgabios_addr)
 		memblock_reserve(virt_to_phys((void *)loongson_sysconf.vgabios_addr),
 				SZ_256K);
+	/* set nid for reserved memory */
+	memblock_set_node((u64)node << 44, (u64)(node+1) << 44, &memblock.reserved, node);
 }
 
 #ifndef CONFIG_NUMA
diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c
index 8f61e93c0c5b..6345e096c532 100644
--- a/arch/mips/loongson64/numa.c
+++ b/arch/mips/loongson64/numa.c
@@ -132,6 +132,8 @@  static void __init node_mem_init(unsigned int node)
 
 		/* Reserve pfn range 0~node[0]->node_start_pfn */
 		memblock_reserve(0, PAGE_SIZE * start_pfn);
+		/* set nid for reserved memory on node 0 */
+		memblock_set_node(0, (u64)1 << 44, &memblock.reserved, 1);
 	}
 }