Skip to contentSkip to conversation

powerpc: Add topology_ready to machdep calls

RFC PATCH In review Geoff Levand 2 participants 5 messages Feb 11, 2009 – Feb 12, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 powerpc: Add topology_ready to machdep calls

Add a new member topology_ready to the powerpc machdep_calls structure.

The NUMA hot plug memory routines require the NUMA node to have been registered via register_one_node() prior to adding memory to the node. The powerpc arch registers NUMA nodes during startup in its topology_init() routine.

Currently, there is no mechanism for the platform code to know when the nodes have been registered, and hence, when it is safe to add hot plug memory.

---
 arch/powerpc/include/asm/machdep.h |    1 +
 arch/powerpc/kernel/sysfs.c        |    3 +++
 2 files changed, 4 insertions(+)
arch/powerpc/include/asm/machdep.h +1 -0
@@ -106,6 +106,7 @@ struct machdep_calls {
 	void		(*setup_arch)(void); /* Optional, may be NULL */
 	void		(*init_early)(void);
 	/* Optional, may be NULL. */
+	void		(*topology_ready)(void); /* Optional, may be NULL */
 	void		(*show_cpuinfo)(struct seq_file *m);
 	void		(*show_percpuinfo)(struct seq_file *m, int i);
 
arch/powerpc/kernel/sysfs.c +3 -0
@@ -647,6 +647,9 @@ static int __init topology_init(void)
 			register_cpu_online(cpu);
 	}
 
+	if (ppc_md.topology_ready)
+		ppc_md.topology_ready();
+
 	return 0;
 }
 subsys_initcall(topology_init);
#1 lore raw

RFC PATCH 1/1 powerpc/ps3: Add ps3_topology_ready routine

Switch the PS3 hotplug memory routine ps3_mm_add_memory() from being a core_initcall routine to being called via the new topology_ready powerpc machdep call.

core_initcall routines run before the powerpc topology_init() startup routine, resulting in failure of ps3_mm_add_memory() when CONFIG_NUMA=y.

---
 arch/powerpc/platforms/ps3/mm.c       |    4 +---
 arch/powerpc/platforms/ps3/platform.h |    1 +
 arch/powerpc/platforms/ps3/setup.c    |    6 ++++++
 3 files changed, 8 insertions(+), 3 deletions(-)
arch/powerpc/platforms/ps3/mm.c +1 -3
@@ -289,7 +289,7 @@ static void ps3_mm_region_destroy(struct
  * ps3_mm_add_memory - hot add memory
  */
 
-static int __init ps3_mm_add_memory(void)
+int __init ps3_mm_add_memory(void)
 {
 	int result;
 	unsigned long start_addr;
@@ -328,8 +328,6 @@ static int __init ps3_mm_add_memory(void
 	return result;
 }
 
-core_initcall(ps3_mm_add_memory);
-
 /*============================================================================*/
 /* dma routines                                                               */
 /*============================================================================*/
arch/powerpc/platforms/ps3/platform.h +1 -0
@@ -37,6 +37,7 @@ void __init ps3_mm_init(void);
 void __init ps3_mm_vas_create(unsigned long* htab_size);
 void ps3_mm_vas_destroy(void);
 void ps3_mm_shutdown(void);
+int __init ps3_mm_add_memory(void);
 
 /* irq */
 
arch/powerpc/platforms/ps3/setup.c +6 -0
@@ -249,6 +249,11 @@ static int __init ps3_probe(void)
 	return 1;
 }
 
+static void __init ps3_topology_ready(void)
+{
+	ps3_mm_add_memory();
+}
+
 #if defined(CONFIG_KEXEC)
 static void ps3_kexec_cpu_down(int crash_shutdown, int secondary)
 {
@@ -267,6 +272,7 @@ define_machine(ps3) {
 	.name				= "PS3",
 	.probe				= ps3_probe,
 	.setup_arch			= ps3_setup_arch,
+	.topology_ready			= ps3_topology_ready,
 	.init_IRQ			= ps3_init_IRQ,
 	.panic				= ps3_panic,
 	.get_boot_time			= ps3_get_boot_time,
#2 lore raw
In reply to Geoff Levand
Quoted 11 lines · Geoff Levand

Add a new member topology_ready to the powerpc machdep_calls structure.

The NUMA hot plug memory routines require the NUMA node to have been registered via register_one_node() prior to adding memory to the node. The powerpc arch registers NUMA nodes during startup in its topology_init() routine.

Currently, there is no mechanism for the platform code to know when the nodes have been registered, and hence, when it is safe to add hot plug memory.

No objection other than the confusion with the /* Optional may be NULL */ comment above the line you added that becomes weirdly placed since it applies, I think, to show_cpuinfo.

Cheers,
Ben.

Quoted 29 lines
---
 arch/powerpc/include/asm/machdep.h |    1 +
 arch/powerpc/kernel/sysfs.c        |    3 +++
 2 files changed, 4 insertions(+)
arch/powerpc/include/asm/machdep.h +1 -0
@@ -106,6 +106,7 @@ struct machdep_calls {
 	void		(*setup_arch)(void); /* Optional, may be NULL */
 	void		(*init_early)(void);
 	/* Optional, may be NULL. */
+	void		(*topology_ready)(void); /* Optional, may be NULL */
 	void		(*show_cpuinfo)(struct seq_file *m);
 	void		(*show_percpuinfo)(struct seq_file *m, int i);
 
arch/powerpc/kernel/sysfs.c +3 -0
@@ -647,6 +647,9 @@ static int __init topology_init(void)
 			register_cpu_online(cpu);
 	}
 
+	if (ppc_md.topology_ready)
+		ppc_md.topology_ready();
+
 	return 0;
 }
 subsys_initcall(topology_init);
#3 lore raw
In reply to Geoff Levand
Quoted 7 lines · Geoff Levand

Add a new member topology_ready to the powerpc machdep_calls structure.

The NUMA hot plug memory routines require the NUMA node to have been registered via register_one_node() prior to adding memory to the node. The powerpc arch registers NUMA nodes during startup in its topology_init() routine.

Just a question.. what's wrong with just using some later kind of initcall ? You want to get the memory added as early as possible ?

Cheers,
Ben.

#4 lore raw

PATCH 1/1 powerpc/ps3: Move ps3_mm_add_memory to device_initcall

In reply to Geoff Levand

Change the PS3 hotplug memory routine ps3_mm_add_memory() from a core_initcall to a device_initcall.

core_initcall routines run before the powerpc topology_init() startup routine, which is a subsys_initcall, resulting in failure of ps3_mm_add_memory() when CONFIG_NUMA=y. When ps3_mm_add_memory() fails the system will boot with just the 128 MiB of boot memory

---
Ben,

Please send upstream for 2.6.29, as this effects the current Fedora 11 development kernel, and maybe other distros which are based on 2.6.29.

 arch/powerpc/platforms/ps3/mm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/ps3/mm.c +1 -1
@@ -328,7 +328,7 @@ static int __init ps3_mm_add_memory(void
 	return result;
 }
 
-core_initcall(ps3_mm_add_memory);
+device_initcall(ps3_mm_add_memory);
 
 /*============================================================================*/
 /* dma routines                                                               */