public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Martin Schwidefsky <schwidefsky@de.ibm.com>
To: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: [patch 10/32] [PATCH] smp: always reboot on cpu 0
Date: Wed, 24 Feb 2010 09:44:40 +0100	[thread overview]
Message-ID: <20100224084449.045600757@de.ibm.com> (raw)
In-Reply-To: 20100224084430.193562869@de.ibm.com

[-- Attachment #1: 109-smp-reboot-cpu0.diff --]
[-- Type: text/plain, Size: 9905 bytes --]

From: Heiko Carstens <heiko.carstens@de.ibm.com>

Always reboot on logical cpu 0. This makes sure that the IPL cpu is
always the same and usually avoids strange numbering schemes between
physical and logical cpus.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---

 arch/s390/include/asm/smp.h      |   12 +++++++
 arch/s390/kernel/Makefile        |    2 +
 arch/s390/kernel/ipl.c           |   31 +++++++++++++++-----
 arch/s390/kernel/machine_kexec.c |   10 +++++-
 arch/s390/kernel/smp.c           |   36 +++++++++++++++++++++++
 arch/s390/kernel/switch_cpu.S    |   59 +++++++++++++++++++++++++++++++++++++++
 arch/s390/kernel/switch_cpu64.S  |   52 ++++++++++++++++++++++++++++++++++
 7 files changed, 191 insertions(+), 11 deletions(-)

Index: quilt-2.6/arch/s390/include/asm/smp.h
===================================================================
--- quilt-2.6.orig/arch/s390/include/asm/smp.h	2010-02-24 09:44:24.000000000 +0100
+++ quilt-2.6/arch/s390/include/asm/smp.h	2010-02-24 09:44:24.000000000 +0100
@@ -31,6 +31,18 @@
 
 extern struct save_area *zfcpdump_save_areas[NR_CPUS + 1];
 
+extern void smp_switch_to_ipl_cpu(void (*func)(void *), void *);
+extern void smp_switch_to_cpu(void (*)(void *), void *, unsigned long sp,
+			      int from, int to);
+extern void smp_restart_cpu(void);
+
+#else /* CONFIG_SMP */
+
+static inline void smp_switch_to_ipl_cpu(void (*func)(void *), void *data)
+{
+	func(data);
+}
+
 #endif /* CONFIG_SMP */
 
 #ifdef CONFIG_HOTPLUG_CPU
Index: quilt-2.6/arch/s390/kernel/ipl.c
===================================================================
--- quilt-2.6.orig/arch/s390/kernel/ipl.c	2010-02-24 09:28:13.000000000 +0100
+++ quilt-2.6/arch/s390/kernel/ipl.c	2010-02-24 09:44:24.000000000 +0100
@@ -553,7 +553,7 @@
 	return rc;
 }
 
-static void ipl_run(struct shutdown_trigger *trigger)
+static void __ipl_run(void *unused)
 {
 	diag308(DIAG308_IPL, NULL);
 	if (MACHINE_IS_VM)
@@ -562,6 +562,11 @@
 		reipl_ccw_dev(&ipl_info.data.ccw.dev_id);
 }
 
+static void ipl_run(struct shutdown_trigger *trigger)
+{
+	smp_switch_to_ipl_cpu(__ipl_run, NULL);
+}
+
 static int __init ipl_init(void)
 {
 	int rc;
@@ -1039,7 +1044,7 @@
 		sprintf(dst + pos, " PARM %s", vmparm);
 }
 
-static void reipl_run(struct shutdown_trigger *trigger)
+static void __reipl_run(void *unused)
 {
 	struct ccw_dev_id devid;
 	static char buf[128];
@@ -1087,6 +1092,11 @@
 	disabled_wait((unsigned long) __builtin_return_address(0));
 }
 
+static void reipl_run(struct shutdown_trigger *trigger)
+{
+	smp_switch_to_ipl_cpu(__reipl_run, NULL);
+}
+
 static void reipl_block_ccw_init(struct ipl_parameter_block *ipb)
 {
 	ipb->hdr.len = IPL_PARM_BLK_CCW_LEN;
@@ -1369,20 +1379,18 @@
 
 static struct kset *dump_kset;
 
-static void dump_run(struct shutdown_trigger *trigger)
+static void __dump_run(void *unused)
 {
 	struct ccw_dev_id devid;
 	static char buf[100];
 
 	switch (dump_method) {
 	case DUMP_METHOD_CCW_CIO:
-		smp_send_stop();
 		devid.devno = dump_block_ccw->ipl_info.ccw.devno;
 		devid.ssid  = 0;
 		reipl_ccw_dev(&devid);
 		break;
 	case DUMP_METHOD_CCW_VM:
-		smp_send_stop();
 		sprintf(buf, "STORE STATUS");
 		__cpcmd(buf, NULL, 0, NULL);
 		sprintf(buf, "IPL %X", dump_block_ccw->ipl_info.ccw.devno);
@@ -1396,10 +1404,17 @@
 		diag308(DIAG308_SET, dump_block_fcp);
 		diag308(DIAG308_DUMP, NULL);
 		break;
-	case DUMP_METHOD_NONE:
-		return;
+	default:
+		break;
 	}
-	printk(KERN_EMERG "Dump failed!\n");
+}
+
+static void dump_run(struct shutdown_trigger *trigger)
+{
+	if (dump_method == DUMP_METHOD_NONE)
+		return;
+	smp_send_stop();
+	smp_switch_to_ipl_cpu(__dump_run, NULL);
 }
 
 static int __init dump_ccw_init(void)
Index: quilt-2.6/arch/s390/kernel/machine_kexec.c
===================================================================
--- quilt-2.6.orig/arch/s390/kernel/machine_kexec.c	2010-02-24 09:28:13.000000000 +0100
+++ quilt-2.6/arch/s390/kernel/machine_kexec.c	2010-02-24 09:44:24.000000000 +0100
@@ -54,11 +54,11 @@
 {
 }
 
-void machine_kexec(struct kimage *image)
+static void __machine_kexec(void *data)
 {
 	relocate_kernel_t data_mover;
+	struct kimage *image = data;
 
-	smp_send_stop();
 	pfault_fini();
 	s390_reset_system();
 
@@ -68,3 +68,9 @@
 	(*data_mover)(&image->head, image->start);
 	for (;;);
 }
+
+void machine_kexec(struct kimage *image)
+{
+	smp_send_stop();
+	smp_switch_to_ipl_cpu(__machine_kexec, image);
+}
Index: quilt-2.6/arch/s390/kernel/Makefile
===================================================================
--- quilt-2.6.orig/arch/s390/kernel/Makefile	2010-02-24 09:28:13.000000000 +0100
+++ quilt-2.6/arch/s390/kernel/Makefile	2010-02-24 09:44:24.000000000 +0100
@@ -32,6 +32,8 @@
 
 obj-$(CONFIG_MODULES)		+= s390_ksyms.o module.o
 obj-$(CONFIG_SMP)		+= smp.o topology.o
+obj-$(CONFIG_SMP)		+= $(if $(CONFIG_64BIT),switch_cpu64.o, \
+							switch_cpu.o)
 obj-$(CONFIG_HIBERNATION)	+= suspend.o swsusp_asm64.o
 obj-$(CONFIG_AUDIT)		+= audit.o
 compat-obj-$(CONFIG_AUDIT)	+= compat_audit.o
Index: quilt-2.6/arch/s390/kernel/smp.c
===================================================================
--- quilt-2.6.orig/arch/s390/kernel/smp.c	2010-02-24 09:44:24.000000000 +0100
+++ quilt-2.6/arch/s390/kernel/smp.c	2010-02-24 09:44:24.000000000 +0100
@@ -90,6 +90,39 @@
 	return 0;
 }
 
+void smp_switch_to_ipl_cpu(void (*func)(void *), void *data)
+{
+	struct _lowcore *lc, *current_lc;
+	struct stack_frame *sf;
+	struct pt_regs *regs;
+	unsigned long sp;
+
+	if (smp_processor_id() == 0)
+		func(data);
+	__load_psw_mask(PSW_BASE_BITS | PSW_DEFAULT_KEY);
+	/* Disable lowcore protection */
+	__ctl_clear_bit(0, 28);
+	current_lc = lowcore_ptr[smp_processor_id()];
+	lc = lowcore_ptr[0];
+	if (!lc)
+		lc = current_lc;
+	lc->restart_psw.mask = PSW_BASE_BITS | PSW_DEFAULT_KEY;
+	lc->restart_psw.addr = PSW_ADDR_AMODE | (unsigned long) smp_restart_cpu;
+	if (!cpu_online(0))
+		smp_switch_to_cpu(func, data, 0, stap(), __cpu_logical_map[0]);
+	while (signal_processor(0, sigp_stop_and_store_status) == sigp_busy)
+		cpu_relax();
+	sp = lc->panic_stack;
+	sp -= sizeof(struct pt_regs);
+	regs = (struct pt_regs *) sp;
+	memcpy(&regs->gprs, &current_lc->gpregs_save_area, sizeof(regs->gprs));
+	memcpy(&regs->psw, &current_lc->st_status_fixed_logout, sizeof(psw_t));
+	sp -= STACK_FRAME_OVERHEAD;
+	sf = (struct stack_frame *) sp;
+	sf->back_chain = regs->gprs[15];
+	smp_switch_to_cpu(func, data, sp, stap(), __cpu_logical_map[0]);
+}
+
 void smp_send_stop(void)
 {
 	int cpu, rc;
@@ -752,7 +785,8 @@
 	get_online_cpus();
 	mutex_lock(&smp_cpu_state_mutex);
 	rc = -EBUSY;
-	if (cpu_online(cpu))
+	/* disallow configuration changes of online cpus and cpu 0 */
+	if (cpu_online(cpu) || cpu == 0)
 		goto out;
 	rc = 0;
 	switch (val) {
Index: quilt-2.6/arch/s390/kernel/switch_cpu64.S
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ quilt-2.6/arch/s390/kernel/switch_cpu64.S	2010-02-24 09:44:24.000000000 +0100
@@ -0,0 +1,52 @@
+/*
+ * 64-bit switch cpu code
+ *
+ * Copyright IBM Corp. 2009
+ *
+ */
+
+#include <asm/asm-offsets.h>
+#include <asm/lowcore.h>
+#include <asm/ptrace.h>
+
+# smp_switch_to_cpu switches to destination cpu and executes the passed function
+# Parameter: %r2 - function to call
+#	     %r3 - function parameter
+#	     %r4 - stack poiner
+#	     %r5 - current cpu
+#	     %r6 - destination cpu
+
+	.section .text
+	.align 4
+	.globl smp_switch_to_cpu
+smp_switch_to_cpu:
+	stmg	%r6,%r15,__SF_GPRS(%r15)
+	lgr	%r1,%r15
+	aghi	%r15,-STACK_FRAME_OVERHEAD
+	stg	%r1,__SF_BACKCHAIN(%r15)
+	larl	%r1,.gprregs
+	stmg	%r0,%r15,0(%r1)
+1:	sigp	%r0,%r6,__SIGP_RESTART	/* start destination CPU */
+	brc	2,1b			/* busy, try again */
+2:	sigp	%r0,%r5,__SIGP_STOP	/* stop current CPU */
+	brc	2,2b			/* busy, try again */
+3:	j	3b
+
+	.globl	smp_restart_cpu
+smp_restart_cpu:
+	larl	%r1,.gprregs
+	lmg	%r0,%r15,0(%r1)
+1:	sigp	%r0,%r5,__SIGP_SENSE	/* Wait for calling CPU */
+	brc	10,1b			/* busy, accepted (status 0), running */
+	tmll	%r0,0x40		/* Test if calling CPU is stopped */
+	jz	1b
+	ltgr	%r4,%r4			/* New stack ? */
+	jz	1f
+	lgr	%r15,%r4
+1:	basr	%r14,%r2
+
+	.section .data,"aw",@progbits
+.gprregs:
+	.rept	16
+	.quad	0
+	.endr
Index: quilt-2.6/arch/s390/kernel/switch_cpu.S
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ quilt-2.6/arch/s390/kernel/switch_cpu.S	2010-02-24 09:44:24.000000000 +0100
@@ -0,0 +1,59 @@
+/*
+ * 31-bit switch cpu code
+ *
+ * Copyright IBM Corp. 2009
+ *
+ */
+
+#include <asm/asm-offsets.h>
+#include <asm/lowcore.h>
+#include <asm/ptrace.h>
+
+# smp_switch_to_cpu switches to destination cpu and executes the passed function
+# Parameter: %r2 - function to call
+#	     %r3 - function parameter
+#	     %r4 - stack poiner
+#	     %r5 - current cpu
+#	     %r6 - destination cpu
+
+	.section .text
+	.align 4
+	.globl smp_switch_to_cpu
+smp_switch_to_cpu:
+	stm	%r6,%r15,__SF_GPRS(%r15)
+	lr	%r1,%r15
+	ahi	%r15,-STACK_FRAME_OVERHEAD
+	st	%r1,__SF_BACKCHAIN(%r15)
+	basr	%r13,0
+0:	la	%r1,.gprregs_addr-0b(%r13)
+	l	%r1,0(%r1)
+	stm	%r0,%r15,0(%r1)
+1:	sigp	%r0,%r6,__SIGP_RESTART	/* start destination CPU */
+	brc	2,1b			/* busy, try again */
+2:	sigp	%r0,%r5,__SIGP_STOP	/* stop current CPU */
+	brc	2,2b			/* busy, try again */
+3:	j	3b
+
+	.globl	smp_restart_cpu
+smp_restart_cpu:
+	basr	%r13,0
+0:	la	%r1,.gprregs_addr-0b(%r13)
+	l	%r1,0(%r1)
+	lm	%r0,%r15,0(%r1)
+1:	sigp	%r0,%r5,__SIGP_SENSE	/* Wait for calling CPU */
+	brc	10,1b			/* busy, accepted (status 0), running */
+	tmll	%r0,0x40		/* Test if calling CPU is stopped */
+	jz	1b
+	ltr	%r4,%r4			/* New stack ? */
+	jz	1f
+	lr	%r15,%r4
+1:	basr	%r14,%r2
+
+.gprregs_addr:
+	.long	.gprregs
+
+	.section .data,"aw",@progbits
+.gprregs:
+	.rept	16
+	.long	0
+	.endr


  parent reply	other threads:[~2010-02-24  8:50 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-24  8:44 [patch 00/32] s390 patch queue for 2.6.34 Martin Schwidefsky
2010-02-24  8:44 ` [patch 01/32] [PATCH] uaccess: implement strict user copy checks Martin Schwidefsky
2010-02-24  8:44 ` [patch 02/32] [PATCH] adapt text to cu3088-removal Martin Schwidefsky
2010-02-24  8:44 ` [patch 03/32] [PATCH] cio: consolidate workqueues Martin Schwidefsky
2010-02-24  8:44 ` [patch 04/32] [PATCH] cio: introduce cio_settle Martin Schwidefsky
2010-02-24  8:44 ` [patch 05/32] [PATCH] cio: wait for channel report Martin Schwidefsky
2010-02-24  8:44 ` [patch 06/32] [PATCH] cio: make wait_events interruptible Martin Schwidefsky
2010-02-24  8:44 ` [patch 07/32] [PATCH] use inline assembly contraints available with gcc 3.3.3 Martin Schwidefsky
2010-02-24  8:44 ` [patch 08/32] [PATCH] zfcpdump: remove cross arch dump support Martin Schwidefsky
2010-02-24  8:44 ` [patch 09/32] [PATCH] smp: rename and add lowcore defines Martin Schwidefsky
2010-02-24  8:44 ` Martin Schwidefsky [this message]
2010-02-24  8:44 ` [patch 11/32] [PATCH] qdio: account processed SBAL during queue scan Martin Schwidefsky
2010-02-24  8:44 ` [patch 12/32] [PATCH] qdio: optimize cache line usage of struct qdio_irq Martin Schwidefsky
2010-02-24  8:44 ` [patch 13/32] [PATCH] add MACHINE_IS_LPAR flag Martin Schwidefsky
2010-02-24  8:44 ` [patch 14/32] [PATCH] sysinfo: fix SYSIB 3,2,2 structure Martin Schwidefsky
2010-02-24  8:44 ` [patch 15/32] [PATCH] spinlock: check virtual cpu running status Martin Schwidefsky
2010-02-24  8:44 ` [patch 16/32] [PATCH] smp: rework sigp code Martin Schwidefsky
2010-02-24  8:44 ` [patch 17/32] [PATCH] Replace ENOTSUPP usage with EOPNOTSUPP Martin Schwidefsky
2010-02-24  8:44 ` [patch 18/32] [PATCH] free_initmem: reduce code duplication Martin Schwidefsky
2010-02-24  8:44 ` [patch 19/32] [PATCH] ccw_device_notify: improve return codes Martin Schwidefsky
2010-02-24  8:44 ` [patch 20/32] [PATCH] Cleanup struct _lowcore usage and defines Martin Schwidefsky
2010-02-24  8:44 ` [patch 21/32] [PATCH] bug: use relative pointers in bug table entries Martin Schwidefsky
2010-02-24  8:44 ` [patch 22/32] [PATCH] use kprobes_built_in() in mm/fault code Martin Schwidefsky
2010-02-24  8:44 ` [patch 23/32] [PATCH] dasd: fix online/offline race Martin Schwidefsky
2010-02-24  8:44 ` [patch 24/32] [PATCH] add z9-ec/z10 instruction to kernel disassembler Martin Schwidefsky
2010-02-24  8:44 ` [patch 25/32] [PATCH] seq_file: convert drivers/s390/ Martin Schwidefsky
2010-02-24  8:44 ` [patch 26/32] [PATCH] codepage conversion of kernel parameter line Martin Schwidefsky
2010-02-24  8:44 ` [patch 27/32] [PATCH] Define new s390 ELF note sections in elf.h Martin Schwidefsky
2010-02-24  8:44 ` [patch 28/32] [PATCH] add support for compressed kernels Martin Schwidefsky
2010-02-24  8:44 ` [patch 29/32] [PATCH] correct vdso version string Martin Schwidefsky
2010-02-24  8:45 ` [patch 30/32] [PATCH] dasd: fix refcounting Martin Schwidefsky
2010-02-24  8:45 ` [patch 31/32] [PATCH] dasd: correct offline processing Martin Schwidefsky
2010-02-24  8:45 ` [patch 32/32] [PATCH] cio: trigger subchannel event at resume time Martin Schwidefsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100224084449.045600757@de.ibm.com \
    --to=schwidefsky@de.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox