Skip to contentSkip to conversation

Reorganise and then fixup the pseries cpu hotplug code

PATCH In review Michael Ellerman 3 participants 4 messages Nov 23, 2006 – Nov 27, 2006 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Reorganise and then fixup the pseries cpu hotplug code

The pseries cpu hotplug code is currently spread between ./kernel/rtas.c, ./platforms/pseries/smp.c and ./platforms/pseries/setup.c. Some of it is not #ifdef CONFIG_HOTPLUG_CPU, but it should be.

So move all the cpu hotplug code into platforms/pseries/hotplug-cpu.c While we're moving, rename studly caps functions to normal caps, they're all static so no harm done. Fixup some long lines also, and make things static that can be, now we're all in the same file.

Currently we unconditionally hookup pSeries_mach_cpu_die to ppc_md.cpu_die, even if we don't have CONFIG_HOTPLUG_CPU enabled. This is wrong, as it signals the sysfs code to create the online attribute for cpu nodes, allowing the user to attempt an offline when it's not actually supported.

There is also a problem on systems that don't have the correct RTAS tokens available to do RTAS-based cpu hotplug, we still indicate via sysfs that we support cpu hotplug - and then attempt to do so with missing RTAS tokens.

Both problems are solved by conditionally registering the cpu hotplug callbacks, only when CONFIG_HOTPLUG_CPU is enabled, and only after we've found the requisite RTAS tokens.

---

Updated to printk if we can't find the RTAS tokens, and to remove the comment about drslot_chrp_cpu etc.

Linas, Srinivasa, can you test that this addresses the problems you were seeing. It should, but it'd be good if you could test it.

cheers

---
 arch/powerpc/kernel/rtas.c                   |   28 --
 arch/powerpc/platforms/pseries/Makefile      |    2 
 arch/powerpc/platforms/pseries/hotplug-cpu.c |  270 +++++++++++++++++++++++++++
 arch/powerpc/platforms/pseries/setup.c       |   12 -
 arch/powerpc/platforms/pseries/smp.c         |  199 -------------------
 include/asm-powerpc/rtas.h                   |    4 
 6 files changed, 272 insertions(+), 243 deletions(-)
arch/powerpc/kernel/rtas.c +0 -28
Index: powerpc/arch/powerpc/kernel/rtas.c
===================================================================
@@ -810,31 +810,6 @@ asmlinkage int ppc_rtas(struct rtas_args
 	return 0;
 }
 
-/* This version can't take the spinlock, because it never returns */
-
-struct rtas_args rtas_stop_self_args = {
-	/* The token is initialized for real in setup_system() */
-	.token = RTAS_UNKNOWN_SERVICE,
-	.nargs = 0,
-	.nret = 1,
-	.rets = &rtas_stop_self_args.args[0],
-};
-
-void rtas_stop_self(void)
-{
-	struct rtas_args *rtas_args = &rtas_stop_self_args;
-
-	local_irq_disable();
-
-	BUG_ON(rtas_args->token == RTAS_UNKNOWN_SERVICE);
-
-	printk("cpu %u (hwid %u) Ready to die...\n",
-	       smp_processor_id(), hard_smp_processor_id());
-	enter_rtas(__pa(rtas_args));
-
-	panic("Alas, I survived.\n");
-}
-
 /*
  * Call early during boot, before mem init or bootmem, to retrieve the RTAS
  * informations from the device-tree and allocate the RMO buffer for userland
@@ -879,9 +854,6 @@ void __init rtas_initialize(void)
 #endif
 	rtas_rmo_buf = lmb_alloc_base(RTAS_RMOBUF_MAX, PAGE_SIZE, rtas_region);
 
-#ifdef CONFIG_HOTPLUG_CPU
-	rtas_stop_self_args.token = rtas_token("stop-self");
-#endif /* CONFIG_HOTPLUG_CPU */
 #ifdef CONFIG_RTAS_ERROR_LOGGING
 	rtas_last_error_token = rtas_token("rtas-last-error");
 #endif
arch/powerpc/platforms/pseries/Makefile +2 -0
Index: powerpc/arch/powerpc/platforms/pseries/Makefile
===================================================================
@@ -10,6 +10,8 @@ obj-$(CONFIG_XICS)	+= xics.o
 obj-$(CONFIG_SCANLOG)	+= scanlog.o
 obj-$(CONFIG_EEH)	+= eeh.o eeh_cache.o eeh_driver.o eeh_event.o
 
+obj-$(CONFIG_HOTPLUG_CPU)	+= hotplug-cpu.o
+
 obj-$(CONFIG_HVC_CONSOLE)	+= hvconsole.o
 obj-$(CONFIG_HVCS)		+= hvcserver.o
 obj-$(CONFIG_HCALL_STATS)	+= hvCall_inst.o
arch/powerpc/platforms/pseries/hotplug-cpu.c new file +270 -0

270 lines not on this page · raw message

arch/powerpc/platforms/pseries/setup.c +0 -12
Index: powerpc/arch/powerpc/platforms/pseries/setup.c
===================================================================
@@ -347,17 +347,6 @@ static int __init pSeries_init_panel(voi
 }
 arch_initcall(pSeries_init_panel);
 
-static void pSeries_mach_cpu_die(void)
-{
-	local_irq_disable();
-	idle_task_exit();
-	xics_teardown_cpu(0);
-	rtas_stop_self();
-	/* Should never get here... */
-	BUG();
-	for(;;);
-}
-
 static int pseries_set_dabr(unsigned long dabr)
 {
 	return plpar_hcall_norets(H_SET_DABR, dabr);
@@ -558,7 +547,6 @@ define_machine(pseries) {
 	.power_off		= rtas_power_off,
 	.halt			= rtas_halt,
 	.panic			= rtas_os_term,
-	.cpu_die		= pSeries_mach_cpu_die,
 	.get_boot_time		= rtas_get_boot_time,
 	.get_rtc_time		= rtas_get_rtc_time,
 	.set_rtc_time		= rtas_set_rtc_time,
arch/powerpc/platforms/pseries/smp.c +0 -199

211 lines not on this page · raw message

include/asm-powerpc/rtas.h +0 -4
Index: powerpc/include/asm-powerpc/rtas.h
===================================================================
@@ -54,8 +54,6 @@ struct rtas_args {
 	rtas_arg_t *rets;     /* Pointer to return values in args[]. */
 };  
 
-extern struct rtas_args rtas_stop_self_args;
-
 struct rtas_t {
 	unsigned long entry;		/* physical address pointer */
 	unsigned long base;		/* physical address pointer */
@@ -223,8 +221,6 @@ extern int rtas_get_error_log_max(void);
 extern spinlock_t rtas_data_buf_lock;
 extern char rtas_data_buf[RTAS_DATA_BUF_SIZE];
 
-extern void rtas_stop_self(void);
-
 /* RMO buffer reserved for user-space RTAS use */
 extern unsigned long rtas_rmo_buf;
 
#1 lore raw
Quoted 7 lines · Michael Ellerman

Updated to printk if we can't find the RTAS tokens, and to remove the comment about drslot_chrp_cpu etc.

Linas, Srinivasa, can you test that this addresses the problems you were seeing. It should, but it'd be good if you could test it.

As I was busy this week, I didn't test your patch. I will do that on monday.

Thanks
Srinivasa DS

#2 lore raw
In reply to Michael Ellerman
Quoted 13 lines · Michael Ellerman

Currently we unconditionally hookup pSeries_mach_cpu_die to ppc_md.cpu_die, even if we don't have CONFIG_HOTPLUG_CPU enabled. This is wrong, as it signals the sysfs code to create the online attribute for cpu nodes, allowing the user to attempt an offline when it's not actually supported.

There is also a problem on systems that don't have the correct RTAS tokens available to do RTAS-based cpu hotplug, we still indicate via sysfs that we support cpu hotplug - and then attempt to do so with missing RTAS tokens.

Both problems are solved by conditionally registering the cpu hotplug callbacks, only when CONFIG_HOTPLUG_CPU is enabled, and only after we've found the requisite RTAS tokens.

Quoted 9 lines

---

Updated to printk if we can't find the RTAS tokens, and to remove the comment about drslot_chrp_cpu etc.

Linas, Srinivasa, can you test that this addresses the problems you were seeing. It should, but it'd be good if you could test it.

I tested your patch,it works fine. I didn't see "online" file on my JS20 system.

Thanks
Srinivasa DS
Linux technology centre
IBM-ISL Bangalore

Quoted 3 lines

cheers

#3 lore raw
In reply to Michael Ellerman
Quoted 5 lines · Michael Ellerman

The pseries cpu hotplug code is currently spread between ./kernel/rtas.c, ./platforms/pseries/smp.c and ./platforms/pseries/setup.c. Some of it is not #ifdef CONFIG_HOTPLUG_CPU, but it should be.

Ack'ed by: Linas Vepstas <[email protected]>

Quoted 2 lines

Linas, Srinivasa, can you test that this addresses the problems you were seeing. It should, but it'd be good if you could test it.

Actually, I was debugging Srinivasa's problem long-distance, which was an internally-reported bugzilla bug that had landed in my lap. I don't actually have a testable config. But, based on this chain of mails, I am happy with the result!

--linas