All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] MIPS: Modify early_parse_mem()
@ 2022-05-24  2:27 Tiezhu Yang
  2022-05-24  2:27 ` [PATCH v2 1/2] MIPS: Return -EINVAL if mem parameter is empty in early_parse_mem() Tiezhu Yang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tiezhu Yang @ 2022-05-24  2:27 UTC (permalink / raw)
  To: Thomas Bogendoerfer; +Cc: Xuefeng Li, linux-mips, linux-kernel

v2: drop patch #2 of v1 series.

Tiezhu Yang (2):
  MIPS: Return -EINVAL if mem parameter is empty in early_parse_mem()
  MIPS: Use memblock_add_node() in early_parse_mem() under CONFIG_NUMA

 arch/mips/kernel/setup.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

-- 
2.1.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] MIPS: Return -EINVAL if mem parameter is empty in early_parse_mem()
  2022-05-24  2:27 [PATCH v2 0/2] MIPS: Modify early_parse_mem() Tiezhu Yang
@ 2022-05-24  2:27 ` Tiezhu Yang
  2022-05-24  2:27 ` [PATCH v2 2/2] MIPS: Use memblock_add_node() in early_parse_mem() under CONFIG_NUMA Tiezhu Yang
  2022-05-24 11:31 ` [PATCH v2 0/2] MIPS: Modify early_parse_mem() Thomas Bogendoerfer
  2 siblings, 0 replies; 4+ messages in thread
From: Tiezhu Yang @ 2022-05-24  2:27 UTC (permalink / raw)
  To: Thomas Bogendoerfer; +Cc: Xuefeng Li, linux-mips, linux-kernel

In the current code, the users usually need to make sure the value
of mem parameter is correct, but it is better to do some check to
avoid potential boot hangs.

This commit checks whether mem parameter is empty, if yes, return
-EINVAL before call memblock_remove() and memblock_add().

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 arch/mips/kernel/setup.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index ad3aea81..1c7f916 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -344,6 +344,11 @@ static int __init early_parse_mem(char *p)
 {
 	phys_addr_t start, size;
 
+	if (!p) {
+		pr_err("mem parameter is empty, do nothing\n");
+		return -EINVAL;
+	}
+
 	/*
 	 * If a user specifies memory size, we
 	 * blow away any automatically generated
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] MIPS: Use memblock_add_node() in early_parse_mem() under CONFIG_NUMA
  2022-05-24  2:27 [PATCH v2 0/2] MIPS: Modify early_parse_mem() Tiezhu Yang
  2022-05-24  2:27 ` [PATCH v2 1/2] MIPS: Return -EINVAL if mem parameter is empty in early_parse_mem() Tiezhu Yang
@ 2022-05-24  2:27 ` Tiezhu Yang
  2022-05-24 11:31 ` [PATCH v2 0/2] MIPS: Modify early_parse_mem() Thomas Bogendoerfer
  2 siblings, 0 replies; 4+ messages in thread
From: Tiezhu Yang @ 2022-05-24  2:27 UTC (permalink / raw)
  To: Thomas Bogendoerfer; +Cc: Xuefeng Li, linux-mips, linux-kernel

Use memblock_add_node to add new memblock region within a NUMA node
in early_parse_mem() under CONFIG_NUMA, otherwise the mem parameter
can not work well.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 arch/mips/kernel/setup.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 1c7f916..2ca156a 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -37,6 +37,7 @@
 #include <asm/cdmm.h>
 #include <asm/cpu.h>
 #include <asm/debug.h>
+#include <asm/mmzone.h>
 #include <asm/sections.h>
 #include <asm/setup.h>
 #include <asm/smp-ops.h>
@@ -364,7 +365,10 @@ static int __init early_parse_mem(char *p)
 	if (*p == '@')
 		start = memparse(p + 1, &p);
 
-	memblock_add(start, size);
+	if (IS_ENABLED(CONFIG_NUMA))
+		memblock_add_node(start, size, pa_to_nid(start), MEMBLOCK_NONE);
+	else
+		memblock_add(start, size);
 
 	return 0;
 }
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/2] MIPS: Modify early_parse_mem()
  2022-05-24  2:27 [PATCH v2 0/2] MIPS: Modify early_parse_mem() Tiezhu Yang
  2022-05-24  2:27 ` [PATCH v2 1/2] MIPS: Return -EINVAL if mem parameter is empty in early_parse_mem() Tiezhu Yang
  2022-05-24  2:27 ` [PATCH v2 2/2] MIPS: Use memblock_add_node() in early_parse_mem() under CONFIG_NUMA Tiezhu Yang
@ 2022-05-24 11:31 ` Thomas Bogendoerfer
  2 siblings, 0 replies; 4+ messages in thread
From: Thomas Bogendoerfer @ 2022-05-24 11:31 UTC (permalink / raw)
  To: Tiezhu Yang; +Cc: Xuefeng Li, linux-mips, linux-kernel

On Tue, May 24, 2022 at 10:27:48AM +0800, Tiezhu Yang wrote:
> v2: drop patch #2 of v1 series.
> 
> Tiezhu Yang (2):
>   MIPS: Return -EINVAL if mem parameter is empty in early_parse_mem()
>   MIPS: Use memblock_add_node() in early_parse_mem() under CONFIG_NUMA
> 
>  arch/mips/kernel/setup.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)

series applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-24 11:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-24  2:27 [PATCH v2 0/2] MIPS: Modify early_parse_mem() Tiezhu Yang
2022-05-24  2:27 ` [PATCH v2 1/2] MIPS: Return -EINVAL if mem parameter is empty in early_parse_mem() Tiezhu Yang
2022-05-24  2:27 ` [PATCH v2 2/2] MIPS: Use memblock_add_node() in early_parse_mem() under CONFIG_NUMA Tiezhu Yang
2022-05-24 11:31 ` [PATCH v2 0/2] MIPS: Modify early_parse_mem() Thomas Bogendoerfer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.